Method: NewRelic::Agent::Heap#initialize

Defined in:
lib/new_relic/agent/heap.rb

#initialize(items = nil, &priority_fn) ⇒ Heap

Returns a new instance of Heap.

Parameters:

  • items (Array) (defaults to: nil)

    an optional array of items to initialize the heap

  • priority_fn (Callable)

    an optional priority function used to to compute the priority for an item. If it’s not supplied priority will be computed using Comparable.

[View source]

26
27
28
29
30
31
# File 'lib/new_relic/agent/heap.rb', line 26

def initialize(items = nil, &priority_fn)
  @items = []
  @priority_fn = priority_fn || ->(x) { x }
  # the following line needs else branch coverage
  items.each { |item| push(item) } if items # rubocop:disable Style/SafeNavigation
end