RCR 162: Binary search
submitted by ch00k on 2003-10-27 09:49:57
This is a legacy RCR. If this is your RCR, please resubmit it using the new format and process.
I propose to add binary search functionality to Enumerable. Add some method can be called for sorted collection (afer sort!) or, maybe it is better to introduce "is-sorted" method or flag
binary_search_first, binary_search_last - to find the first and the last occurence of object with given property
binary_search_all - to return Array of found objects (or iterate a block over them?)
Vote for this RCR
Add comments here
not all objects that include Enumerable have a [] operator or are even indexable. Adding this would mean there would be methods in Enumerable that don't work on all Enumerable objects.
Then maybe add 'Indexable' module?
Back to RCRchive.
RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog