Equivilent of STL Set in D ? ...

Walter Bright newshound at digitalmars.com
Fri Oct 20 18:50:40 PDT 2006


KlausO wrote:
> clayasaurus wrote:
>>
>> Thanks for the info, so all I have to do is create a balanced binary 
>> tree with a foreach iterator? :) Seems simple enough.
>>
>> ~ Clay
> 
> Nova contains an intrusive red/black tree implementation:
> 
> http://www.dsource.org/projects/nova/browser/trunk/NOVA/DS/intrusive/redblacktree.d 

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. I should be able to just:

import whatever.redblacktree;

RedBlackTree(char[], int) foo;	// create a red-black tree with key 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);



More information about the Digitalmars-d-learn mailing list