On Mon, 19 Jul 2010 09:36:54 -0400, Andrei Alexandrescu <[email protected]> wrote:

On 07/19/2010 06:36 AM, Steven Schveighoffer wrote:
Just thinking out loud here, couldn't you use the predicate already in
AssumeSorted? I mean, if you're going to pass AssumeSorted into find,
you don't want to also specify the predicate as then the range just
becomes a standard range.

There must be some kind of way to use template constraints to kill the
predicate arg to find when the range is an AssumeSorted struct. If not,
there should be.

That's a good idea. The find predicate that could be derived from AssumeSorted's predicate pred would be !pred(a, b) && !pred(b, a).

Thanks, Steve.

You're welcome :)

BTW, you don't need the combo predicate until the very end. Basically, you do a binary search for the first element where pred(a, E) is false (where E is the target), and then see if pred(E, a) is also false on that element (to test for equality).

-Steve

Reply via email to