tyler/binary_search

Improve binary_index and binary_search

Closed this issue · 1 comments

I am planning on using this gem, but need additional functionality. I am working on a patch which will:

  • Add tests.
  • Allow both binary_index and binary_search to take an argument OR a block.
  • Add a method (either new or a common one) which will return the index values which is less than the desired value, if it is not found. In my application, "closest" is good enough. If the value is greater than the first element, -1 will be returned. If it's larger than the final argument, array.size will be returned.

If I complete this, would you want to merge this in, or should I fork the gem? These are some significant changes, so I'd understand if you would rather a fork under a new name.

Pull request in #8.