Method: PEROBS::BTreeNode#search_key_index

Defined in:
lib/perobs/BTreeNode.rb

#search_key_index(key) ⇒ Integer

Search the keys of the node that fits the given key. The result is either the index of an exact match or the index of the position where the given key would have to be inserted.

Parameters:

  • key (Integer)

    key to search for

Returns:

  • (Integer)

    Index of the matching key or the insert position.



602
603
604
605
# File 'lib/perobs/BTreeNode.rb', line 602

def search_key_index(key)
  (@is_leaf ? @keys.bsearch_index { |x| x >= key } :
              @keys.bsearch_index { |x| x > key }) || @keys.length
end