Namespace

Methods

Class Index [+]

Quicksearch

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 1073
1073:   def self.binary_search(ary, value, &block)
1074:     upper = ary.size - 1
1075:     lower = 0
1076:     idx = 0
1077: 
1078:     while(lower <= upper) do
1079:       idx = (lower + upper) / 2
1080:       comp = ary[idx].value <=> value
1081: 
1082:       if comp == 0
1083:         return idx
1084:       elsif comp > 0
1085:         upper = idx - 1
1086:       else
1087:         lower = idx + 1
1088:       end
1089:     end
1090:     return upper
1091:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.