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.



410
411
412
# File 'lib/drip.rb', line 410

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

Instance Method Details

#lower_bound(pair) ⇒ Object



422
423
# File 'lib/drip.rb', line 422

def lower_bound(pair)
end

#upper_bound(pair) ⇒ Object



414
415
416
417
418
419
420
# File 'lib/drip.rb', line 414

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