Giraffe.PriorityQueue (giraffe v0.2.0)

A Priority Queue implementation using a list-based heap structure. Lower priority values are dequeued first.

Summary

Functions

Dequeues the item with the lowest priority Returns {item, new_queue} or :empty if queue is empty

Checks if the queue is empty

Enqueues an item with a given priority

Creates a new empty priority queue

Returns the highest priority item without removing it from the queue Returns {:ok, item} or :empty if queue is empty

Returns the size of the queue

Types

t()

@type t() :: %Giraffe.PriorityQueue{items: [{number(), any()}]}

Functions

dequeue(priority_queue)

Dequeues the item with the lowest priority Returns {item, new_queue} or :empty if queue is empty

empty?(priority_queue)

Checks if the queue is empty

enqueue(priority_queue, priority, value)

Enqueues an item with a given priority

new()

@spec new() :: t()

Creates a new empty priority queue

peek(priority_queue)

Returns the highest priority item without removing it from the queue Returns {:ok, item} or :empty if queue is empty

size(priority_queue)

Returns the size of the queue