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 1159
1159:   def self.binary_search(ary, value, &block)
1160:     upper = ary.size - 1
1161:     lower = 0
1162:     idx = 0
1163: 
1164:     while(lower <= upper) do
1165:       idx = (lower + upper) / 2
1166:       comp = ary[idx].value <=> value
1167: 
1168:       if comp == 0
1169:         return idx
1170:       elsif comp > 0
1171:         upper = idx - 1
1172:       else
1173:         lower = idx + 1
1174:       end
1175:     end
1176:     return upper
1177:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.