ri > Concurrent::Collection::NonConcurrentPriorityQueue

๐Ÿ“– NAME

Concurrent::Collection::NonConcurrentPriorityQueue < NonConcurrentPriorityQueueImplementation

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ†• Create a priority queuequeue = Concurrent::Collection::NonConcurrentPriorityQueue.new๐ŸŽฏ Creates a new nonโ€‘threadโ€‘safe priority queue (default order: highest first)
โž• Add an elementqueue.push(element)๐Ÿ“ฅ Inserts an element at the correct position based on priority
โฌ†๏ธ Remove highest priority elementelement = queue.pop๐Ÿ—‘๏ธ Removes and returns the element with the highest priority
๐Ÿ‘๏ธ Peek at highest priorityqueue.peek๐Ÿ” Returns the highest priority element without removing it
โ“ Check if emptyqueue.empty?โœ… Returns true if the queue has no elements
๐Ÿ“ Get sizequeue.length๐Ÿ”ข Returns the number of elements in the queue
๐Ÿงน Clear the queuequeue.clear๐Ÿšฎ Removes all elements

๐Ÿ“ Description

๐ŸŽฏ 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.

โš ๏ธ Note: This implementation is not thread safe.

๐Ÿ”— See Also

Concurrent::Collection::NonConcurrentPriorityQueue
๐Ÿ“– NAME ๐Ÿš€ Quick Reference ๐Ÿ“ Description ๐Ÿ”— See Also

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-29 18:42 @216.73.216.177
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format