D library projects
Steven Schveighoffer
schveiguy at yahoo.com
Sun Nov 15 15:16:09 PST 2009
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, 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.
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.
-Steve
More information about the Digitalmars-d
mailing list