Giter Site home page Giter Site logo

onnple / priorityqueue Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 3 KB

最小二叉堆(binary heap)实现优先队列,原文地址:http://www.srcmini.com/1588.html

Home Page: http://www.srcmini.com/

C 100.00%
heap priority-queue min-heap datastructures algorithms

priorityqueue's Introduction

优先队列(PriorityQueue)

最小二叉堆(binary heap)实现优先队列,原文地址:

最小堆优先队列操作函数说明:

1、初始化最小堆优先队列

extern PriorityQueue *pqueue_init(int length);

2、检查最小堆优先队列是否为空

extern int pqueue_is_empty(PriorityQueue *queue);

3、检查最小堆优先队列是否已满

extern int pqueue_is_full(PriorityQueue *queue);

4、最小堆优先队列入队

extern int pqueue_push(PriorityQueue *queue, int key, Song *song);

5、获取队列顶部元素

extern QNode *pqueue_top(PriorityQueue *queue); // 获取顶部元素

6、顶部元素出队

extern int pqueue_pop(PriorityQueue *queue); // 释放顶部元素

7、index位置的元素降低delta

extern int pqueue_decrease(PriorityQueue *queue, int index, int delta);

8、index位置的元素提升delta

extern int pqueue_increase(PriorityQueue *queue, int index, int delta);

9、删除index位置的元素

extern int pqueue_delete(PriorityQueue *queue, int index);

10、使用一个数组构建一个优先队列

extern PriorityQueue *pqueue_build(QNode *list, int length);

11、遍历优先队列

extern void pqueue_traverse(PriorityQueue *queue);

12、释放优先队列

extern int pqueue_clear(PriorityQueue *queue);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.