Skewlia.jl
Skewlia.Skewlia
— ModuleSkewlia - mergable priority queues
heap = Skewlia.SkewHeap()
# Insert one at a time
for job in some_list_of_jobs
Skewlia.put!(heap, job)
end
# Insert all at once
Skewlia.put!(heap, some_list_of_jobs...)
# Retrieve jobs in order (using <=)
while !Skewlia.is_empty(heap)
job = Skewlia.get!(heap)
do_stuff_with(job)
end
# Or as an iterator
for job in heap
do-stuff_with(job)
end
Skewlia.SkewHeap
— TypeSkewHeap() ::SkewHeap
Initialize a new skew heap. Elements inserted into the heap will be ordered using <=
.
Base.iterate
— Functioniterate(h::SkewHeap)
Returns an iterator that will sequentially retrieve each item from the heap. Adding new items while iterating over the heap is perfectly acceptable.
heap = Skewlia.SkewHeap()
Skewlia.put!("foo", "bar", "baz", "bat")
for abused_string in heap
println(abused_string)
end
Skewlia.explain
— Methodexplain(h::SkewHeap)
Prints out the structure of the heap for debugging.
Skewlia.is_empty
— Methodis_empty(h::SkewHeap)
Returns true if the heap is empty.
Skewlia.length
— Methodlength(h::SkewHeap)
Returns the number of items in the heap.
Skewlia.peek
— Methodpeek(h::SkewHeap)
Returns the next item from the heap without removing it, or nothing
if empty.
Skewlia.put!
— Methodput(h::SkewHeap, items...)
Inserts new items into the heap and returns the heap's new size.
Skewlia.take!
— Methodtake(h::SkewHeap)
Removes and returns the next item from the heap or nothing
if it is empty.