Equivilent of STL Set in D ? ...

KlausO oberhofer at users.sourceforge.net
Sat Oct 21 13:22:10 PDT 2006


Walter Bright wrote:
> 
> Looks like you've already done it! It seems a little complex to use, 
> however. It shouldn't be necessary to define new classes/structs in 
> order to use it. 

That's because it's the intrusive form of a red black tree.

Clay had some questions about them I tried to answer:
http://www.dsource.org/forums/viewtopic.php?t=1959

> I should be able to just:
> 
> import whatever.redblacktree;
> 
> RedBlackTree(char[], int) foo;    // create a red-black tree with key 

:-) I guess you meant
   RedBlackTree!(char[], int) foo;

> type of char[] and value type of int.
> 
> ...
> foo["hello"] = 3;
> foo["betty"] = 25;
> bar(foo["hello"]);    // bar(3)
> foo.remove("betty"));
> ...
> foreach (v; foo)
>     writefln("value is %s", v);

Seems to be an interesting task to get used to the new foreach
features. I'll give it a try.

Klaus



More information about the Digitalmars-d-learn mailing list