trevnorris/cbuffer — pull request #14 by megawac (2014-08-06 20:41:15+00:00)
Title: Add binary sortedIndex

I'm building a tool to join multiple streams by the nearest time stamp. The streams may not be in sync so I plan to store the last `n` (probably >=500) items in a fixed size circular buffer. I'd like to use a `sortedIndex` (similar to underscores) to find where an item would be placed in a sorted buffer. I need this index to find the item just before and just after the time stamp.

Right now the only problem remaining (as far as I can tell) with this code is the operation at the to return a "nice" index instead of the index in `data`. If you have an idea I'd appreciate it, otherwise I'll look at this again in a couple days.

Sorry about the reformatting, was working in spaces and converted to tabs at the end. I can recommit if you want