https://github.com/davecom/c3priorityqueue
A simple binary heap based priority queue for C3.
https://github.com/davecom/c3priorityqueue
Last synced: 20 days ago
JSON representation
A simple binary heap based priority queue for C3.
- Host: GitHub
- URL: https://github.com/davecom/c3priorityqueue
- Owner: davecom
- License: mit
- Created: 2022-07-13T02:01:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-16T06:53:18.000Z (over 3 years ago)
- Last Synced: 2025-11-21T09:03:20.878Z (4 months ago)
- Size: 185 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C3PriorityQueue
This is a simple binary heap based priority queue for the [C3 language](https://github.com/c3lang/c3c). As such, it has O(lg n) pushes and pops. It depends on the intrinsic comparability of a type (`<` or `>`). You can configure the `max` property to make it a min-heap (false/default) or max-heap (true) based priority queue (do you want the smallest or largest value each time you pop?).
## Example
```c3
define IntPriorityQueue = PriorityQueue;
fn void myThing() {
IntPriorityQueue pq;
pq.push(3);
pq.push(1);
pq.push(5);
pq.pop(); // expect to have 1 returned, or if you configured it as a max heap, then 5
}
```