[Dune-devel] [Dune-Commit] [Commit] dune-istl - 1ede1c9: Cleanup: don't hand-implement binary search -- use std::lower_bound instead

Oliver Sander sander at igpm.rwth-aachen.de
Wed Jul 3 16:43:38 CEST 2013


Hi Markus,

Am 03.07.2013 15:20, schrieb Markus Blatt:
> Hi Oliver,
>
> On Wed, Jul 03, 2013 at 01:51:06PM +0200, Oliver Sander wrote:

[snip]

>
> Couldn't we use std:find instead?
> return iterator(p, j, std::find(j, j+n, i)-j);
>
> In case the value is not foun find returns j+n, anyway. Or is there
> some performance issue that I fail to see?
>
> Markus
>

std::find does not assume that the container is sorted, and consequently
does a linear sort.  OTOH, std::lower_bound is O(log n) on a random
access container.

Best,
Oliver




More information about the Dune-devel mailing list