__replace_next_larger (Diff::LCS)

         # File lib/diff/lcs.rb, line 879
    879:     def __replace_next_larger(enum, value, last_index = nil)
    880:         # Off the end?
    881:       if enum.empty? or (value > enum[-1])
    882:         enum << value
    883:         return enum.size - 1
    884:       end
    885:
    886:         # Binary search for the insertion point
    887:       last_index ||= enum.size
    888:       first_index = 0
    889:       while (first_index <= last_index)
    890:         ii = (first_index + last_index) >> 1
    891:
    892:         found = enum[ii]
    893:
    894:         if value == found
    895:           return nil
    896:         elsif value > found
    897:           first_index = ii + 1
    898:         else
    899:           last_index = ii - 1
    900:         end
    901:       end
    902:
    903:         # The insertion point is in first_index; overwrite the next larger
    904:         # value.
    905:       enum[first_index] = value
    906:       return first_index
    907:     end