kiuKisas / th_prim_queue

thread safe priority queue implementation in pure Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thread safe Priority Queue

A thread safe priority queue implementation in pure Ruby which tends to mimic the original ruby queue in use.

Complexity

It use a binary search to order the queue, so the complexity increases about O(log(n)) at every push.

Usage

initialize(elems=nil, &block)

initialize takes two optionals parameters:

  • elems that you can store in queue, it must be an array
  • a lambda which will be use to sort the queue. By default, it sort by descendant order like this: lambda { |a,b| a >= b }

For the rest, it's rather the same as ruby queue.

To Do

  • tests

License

This code is under Beer-Ware Licence, you can see LICENCE.md for more information.

About

thread safe priority queue implementation in pure Ruby

License:Other


Languages

Language:Ruby 100.0%