More flexible sorted ranges?

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 2 12:06:50 PST 2014


On Sunday, 2 November 2014 at 19:54:38 UTC, Xinok wrote:
> D got it right. C++ returns an iterator which can be a bit 
> confusing. D returns a slice so it's meaning is much clearer.
>

No, according to docs D has defined the lower bound to be the 
negation of the lower bound…

> https://en.wikipedia.org/wiki/Upper_and_lower_bounds

Quoting your link:
«5 is lower bound for the set { 5, 10, 34, 13934 }»

Hence if you lowerBound(4) the sequence

[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

it should return

[ 4, 5, 6, 7, 8, 9 ]

not

[ 0, 1, 2, 3 ]

http://dlang.org/phobos/std_range.html#.SortedRange.lowerBound


More information about the Digitalmars-d-learn mailing list