Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hnc-agency/hnc-pq
hnc-pq - Erlang priority queues
https://github.com/hnc-agency/hnc-pq
erlang priority-queue
Last synced: about 1 month ago
JSON representation
hnc-pq - Erlang priority queues
- Host: GitHub
- URL: https://github.com/hnc-agency/hnc-pq
- Owner: hnc-agency
- License: isc
- Created: 2020-10-13T14:45:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-06T15:27:55.000Z (about 3 years ago)
- Last Synced: 2024-08-06T16:46:20.414Z (5 months ago)
- Topics: erlang, priority-queue
- Language: Erlang
- Homepage:
- Size: 154 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hnc-pq - Erlang priority queues
:link: [API documentation (EDoc)](//hnc-agency.github.io/hnc-pq)
`hnc-pq` implements priority queues, built on
regular Erlang queues.## Usage Example
```erlang
%% Create a new hnc_pq instance with
%% 3 priorities: high, normal, and low
PQ0=hnc_pq:new([high, normal, low]).%% Enqueue an item with high priority.
PQ1=hnc_pq:in(high, item_high, PQ0).%% Enqueue another item with normal priority.
PQ2=hnc_pq:in(normal, item_normal, PQ1).%% Enqueue yet another item with low priority.
PQ3=hnc_pq:in(low, item_low, PQ2).%% Dequeue an item. Highest-priority items get
%% dequeued first.
{item_high, PQ4}=hnc_pq:out(PQ3).%% Dequeue another item. As the high-priority
%% queue is empty by now, it is dequeued by
%% the next-highest priority queue (normal).
{item_normal, PQ5}=hnc_pq:out(PQ4).%% Dequeue yet another item. As both the
%% high- and normal-priority queues are now
%% empty, it is dequeued from the next-highest
%% priority queue (low).
{item_low, PQ6}=hnc_pq:out(PQ5).%% All queues are now empty.
empty=hnc_pq:out(PQ6).
```## Usage as a dependency
### `Erlang.mk`
```
DEPS = hnc_pq
dep_hnc_pq = git https://github.com/hnc-agency/hnc-pq 0.1.2
```### `rebar3`
```
{deps, [
{hnc, ".*", {git, "https://github.com/hnc-agency/hnc-pq",
{tag, "0.1.2"}}}
]}.
```## Authors
* Maria Scott (`Maria-12648430`)
* Jan Uhlig (`juhlig`)