Red black trees

Walter Bright newshound at digitalmars.com
Thu Oct 26 17:15:05 PDT 2006


Frits van Bommel wrote:
> Well, I suppose the user is likely to be some library class anyway:
> 
> struct Tuple(Key, Value) { ... }
> 
> class Map(Key, Value) : RedBlackTree!(Tuple(Key, Value)) {
>     // Some extra methods
> }

I use associative arrays, and I never use them like that <g>. They 
always have a key/value. Shouldn't rbtrees be simply an alternate 
container that has the same interface, but has different operating 
characteristics?

> Will you at least consider something like this:
> 
>>> Though you could also allow Value to be void and specialize the node 
>>> type for that so it doesn't contain a Value in that case. Maybe even 
>>> make void the default type for Value?

You could do that, though I'd call the result something else (like the 
Set type you mentioned).




More information about the Digitalmars-d mailing list