passing predicates to lowerBound, or alternatively, how lazy is map?
Andrew Brown via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 11 06:20:36 PDT 2014
>
> You are correct. assumeSorted and lowerBound will provide
> better time complexity than countUntil
I'm sorry, one final question because I think I'm close to
understanding. Map produces a forward range (lazily) but not a
random access range? Therefore, lowerBound will move along this
range until the pred is not true? This means it would be better
to do:
numbers.indexed(order).assumeSorted.lowerBound
than:
map(a => numbers[a])(order).assumeSorted.lowerBound
as the lowerBound will be faster on a random access range as
produced by indexed?
More information about the Digitalmars-d-learn
mailing list