std.container.RedBlackTree versus C++ std::set

Steven Schveighoffer schveiguy at yahoo.com
Fri Feb 15 15:41:51 PST 2013


On Fri, 15 Feb 2013 17:49:53 -0500, monarch_dodra <monarchdodra at gmail.com>  
wrote:

> On Friday, 15 February 2013 at 22:06:55 UTC, Steven Schveighoffer wrote:
>> With opcmp:
>>
>> int opCmp(int a, int b)
>> {
>>    return a - b;
>> }
>
> Genius!
>
> Now I feel bad for every time I've done integral opCmp with double  
> ternary operators :(

Actually, I'm not as smart as you think ;)

There needs to be some extra checking, possibly with the carry flag.

For example:

0x70000000 - (-0x70000000)

would be less than zero as a resulting integer.

But it would work with shorts or bytes!

In any case, the example was bad, the point that which is better depends  
on the situation is still correct.

-Steve


More information about the Digitalmars-d-learn mailing list