Namespace

Methods

Continuum

Constants

POINTS_PER_SERVER

Public Class Methods

binary_search(ary, value, &block) click to toggle source

Find the closest index in Continuum with value <= the given value

# File lib/memcache.rb, line 1158
def self.binary_search(ary, value, &block)
  upper = ary.size - 1
  lower = 0
  idx = 0

  while(lower <= upper) do
    idx = (lower + upper) / 2
    comp = ary[idx].value <=> value

    if comp == 0
      return idx
    elsif comp > 0
      upper = idx - 1
    else
      lower = idx + 1
    end
  end
  return upper
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.