D library projects

Denis Koroskin 2korden at gmail.com
Sun Nov 15 23:07:47 PST 2009


On Mon, 16 Nov 2009 02:16:09 +0300, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Sun, 15 Nov 2009 15:53:08 -0500, BLS <windevguy at hotmail.de> wrote:
>
>
>>
>> ==
>> Now : Sorry for my ignorance ... but Why the heck :
>>
>> struct RBNode(V)
>>
>> instead of :
>>
>> struct RBNode(K, V)
>>
>
> It was my way of providing the exact same implementation for TreeMap,  
> TreeSet, and TreeMultiSet  (same deal between HashMap and HashSet, and  
> HashMultiSet).  TreeSet and TreeMultiSet have no keys,

I'd say it has no values but keys.

> so the basic difference between them is the comparator function for  
> TreeMap (which is passed in by the class to the impl) compares only the  
> keys.
>

That's the key! Maybe I'm missing something, but when do you need to  
compare values?

> So hopefully, if you create a specialized implementation for TreeMap, it  
> can be fed into TreeSet and TreeMultiSet, and you get 3 containers for  
> the price of one :)
>
> If you can think of a better way, I would be glad to consider it.
>



More information about the Digitalmars-d mailing list