Module: Lite::Containers::AvlTree::Find::ExactOrNearestBackwards

Includes:
Inexact
Included in:
Implementation::Max::ExactOrNearestBackwards, Implementation::Min::ExactOrNearestBackwards
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



66
67
68
# File 'lib/lite/containers/avl_tree/find.rb', line 66

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

#lookup_path(node, comparison_result) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/lite/containers/avl_tree/find.rb', line 70

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