Class: Concurrent::Collection::NonConcurrentPriorityQueue
Relationships & Source Files | |
Inherits: |
Concurrent::Collection::NonConcurrentPriorityQueueImplementation
|
Defined in: | lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb |
Overview
This implementation is not thread safe.
A queue collection in which the elements are sorted based on their comparison (spaceship) operator <=>
. Items are added to the queue at a position relative to their priority. On removal the element with the “highest” priority is removed. By default the sort order is from highest to lowest, but a lowest-to-highest sort order can be set on construction.
The API is based on the Queue
class from the Ruby standard library.
The pure Ruby implementation, RubyNonConcurrentPriorityQueue
uses a heap algorithm stored in an array. The algorithm is based on the work of Robert Sedgewick and Kevin Wayne.
The JRuby native implementation is a thin wrapper around the standard library java.util.NonConcurrentPriorityQueue
.
When running under JRuby the class NonConcurrentPriorityQueue
extends JavaNonConcurrentPriorityQueue
. When running under all other interpreters it extends RubyNonConcurrentPriorityQueue
.
Class Method Summary
- .from_list(list, opts = {})
- .new(opts = {}) constructor
Instance Method Summary
Constructor Details
.new(opts = {})
[ GitHub ]Class Method Details
.from_list(list, opts = {})
[ GitHub ]Instance Method Details
#<<
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb', line 59
alias_method :<<, :push
#clear
[ GitHub ]#delete(item)
[ GitHub ]#deq
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb', line 56
alias_method :deq, :pop
#empty?
[ GitHub ]#enq
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb', line 60
alias_method :enq, :push
#has_priority?
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb', line 52
alias_method :has_priority?, :include?
#include?(item)
[ GitHub ]#length
[ GitHub ]#peek
[ GitHub ]#pop
[ GitHub ]#push(item)
[ GitHub ]#shift
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb', line 57
alias_method :shift, :pop
#size
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb', line 54
alias_method :size, :length