Class: TreeMap::BoundedMap::BoundedNodeIterator

Inherits:
NodeIterator
  • Object
show all
Defined in:
lib/treemap/bounded_map.rb

Overview

in-order traversal of nodes in tree

Instance Method Summary collapse

Methods inherited from NodeIterator

#has_next?

Constructor Details

#initialize(bounded_map, next_node) ⇒ BoundedNodeIterator

Returns a new instance of BoundedNodeIterator.



340
341
342
343
# File 'lib/treemap/bounded_map.rb', line 340

def initialize(bounded_map, next_node)
  super(next_node)
  @bounded_map = bounded_map
end

Instance Method Details

#step_backwardObject



351
352
353
354
355
# File 'lib/treemap/bounded_map.rb', line 351

def step_backward
  result = super
  @next_node = nil if @next_node && !@bounded_map.in_closed_bounds?(@next_node.key, @bounded_map.from_bound, Bound::NO_BOUND)
  result
end

#step_forwardObject



345
346
347
348
349
# File 'lib/treemap/bounded_map.rb', line 345

def step_forward
  result = super
  @next_node = nil if @next_node && !@bounded_map.in_closed_bounds?(@next_node.key, Bound::NO_BOUND, @bounded_map.to_bound)
  result
end