Class: Drip::FakeRBTree

Inherits:
Object
  • Object
show all
Includes:
ArrayBsearch
Defined in:
lib/drip.rb

Instance Method Summary collapse

Methods included from ArrayBsearch

lower_boundary, upper_boundary

Constructor Details

#initializeFakeRBTree

Returns a new instance of FakeRBTree.



432
433
434
# File 'lib/drip.rb', line 432

def initialize
  @tree = Hash.new {|h, k| h[k] = Array.new}
end

Instance Method Details

#lower_bound(pair) ⇒ Object



444
445
# File 'lib/drip.rb', line 444

def lower_bound(pair)
end

#upper_bound(pair) ⇒ Object



436
437
438
439
440
441
442
# File 'lib/drip.rb', line 436

def upper_bound(pair)
  tag, now = pair
  return nil unless @tree.include?(tag)
  ary = @tree[tag]
  idx = upper_boundary(ary, now)
  [tag, ary[tag][idx]]
end