kanwei / algorithms

Ruby algorithms and data structures. C extensions
http://kanwei.github.io/algorithms/
MIT License
2.67k stars 352 forks source link

Binary search should return index #13

Open jgross206 opened 12 years ago

jgross206 commented 12 years ago

It would be great if the binary search method return the index of the object in the array instead of the object itself. The index gives you more information (where it is instead of just whether or not it exists) and it's free-- you already have it when returning.