/usr/lib/ruby/vendor_ruby/concurrent/collection/java_non_concurrent_priority_queue.rb is in ruby-concurrent 1.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | if Concurrent.on_jruby?
module Concurrent
module Collection
# @!macro priority_queue
#
# @!visibility private
# @!macro internal_implementation_note
class JavaNonConcurrentPriorityQueue
# @!macro priority_queue_method_initialize
def initialize(opts = {})
order = opts.fetch(:order, :max)
if [:min, :low].include?(order)
@queue = java.util.PriorityQueue.new(11) # 11 is the default initial capacity
else
@queue = java.util.PriorityQueue.new(11, java.util.Collections.reverseOrder())
end
end
# @!macro priority_queue_method_clear
def clear
@queue.clear
true
end
# @!macro priority_queue_method_delete
def delete(item)
found = false
while @queue.remove(item) do
found = true
end
found
end
# @!macro priority_queue_method_empty
def empty?
@queue.size == 0
end
# @!macro priority_queue_method_include
def include?(item)
@queue.contains(item)
end
alias_method :has_priority?, :include?
# @!macro priority_queue_method_length
def length
@queue.size
end
alias_method :size, :length
# @!macro priority_queue_method_peek
def peek
@queue.peek
end
# @!macro priority_queue_method_pop
def pop
@queue.poll
end
alias_method :deq, :pop
alias_method :shift, :pop
# @!macro priority_queue_method_push
def push(item)
raise ArgumentError.new('cannot enqueue nil') if item.nil?
@queue.add(item)
end
alias_method :<<, :push
alias_method :enq, :push
# @!macro priority_queue_method_from_list
def self.from_list(list, opts = {})
queue = new(opts)
list.each{|item| queue << item }
queue
end
end
end
end
end
|