On Sunday, 7 June 2015 at 18:50:47 UTC, anonymous wrote:
On Sunday, 7 June 2015 at 18:42:58 UTC, Dennis Ritchie wrote:
How do I remove the key from the `redBlackTree` with comparator "a <= b" ?

Do not use '<=' as a comparison function with RedBlackTree. It doesn't meet the requirements.

Quoting the documentation [1]:
Note that less should produce a strict ordering. That is, for two unequal elements a and b, less(a, b) == !less(b, a). less(a, a) should always equal false.

This doesn't hold for '<='.

OK. But I want to return a `upperBound` segment with the included `key`. It does not suit me:

auto rbt = redBlackTree!("a < b", int)(1, 2, 3, 4, 5);
writeln(rbt.upperBound(3)); // prints [4, 5]

I want it to be so:

auto rbt = redBlackTree!("a <= b", int)(1, 2, 3, 4, 5);
writeln(rbt.upperBound(3)); // prints [3, 4, 5]

How do I do with the comparator "a < b" ?

Reply via email to