Class: RxRuby::PriorityQueue::IndexedItem

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/rx_ruby/internal/priority_queue.rb

Constant Summary collapse

@@length =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ IndexedItem

Returns a new instance of IndexedItem.



107
108
109
110
# File 'lib/rx_ruby/internal/priority_queue.rb', line 107

def initialize(value)
  @id = @@length += 1
  @value = value
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



103
104
105
# File 'lib/rx_ruby/internal/priority_queue.rb', line 103

def id
  @id
end

#valueObject (readonly)

Returns the value of attribute value.



103
104
105
# File 'lib/rx_ruby/internal/priority_queue.rb', line 103

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



112
113
114
115
116
117
118
# File 'lib/rx_ruby/internal/priority_queue.rb', line 112

def <=>(other)
  if @value == other.value
    @id <=> other.id
  else
    @value <=> other.value
  end
end