Module: Lite::Containers::AvlTree::Find::ExactOrNearestForwards

Includes:
Inexact
Included in:
Implementation::Max::ExactOrNearestForwards, Implementation::Min::ExactOrNearestForwards
Defined in:
lib/lite/containers/avl_tree/find.rb

Instance Method Summary collapse

Methods included from Inexact

#find, #find_candidate

Instance Method Details

#lookup_direction(search_key, node_key) ⇒ Object



83
84
85
# File 'lib/lite/containers/avl_tree/find.rb', line 83

def lookup_direction(search_key, node_key)
  compare(node_key, search_key)
end

#lookup_path(node, comparison_result) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/lite/containers/avl_tree/find.rb', line 87

def lookup_path(node, comparison_result)
  case comparison_result
  when -1 then node.right
  when 1 then node.left
  else
    raise Helpers::Comparison::Error, "Unexpected comparison result: #{comparison_result}"
  end
end