Immutable Red-Black trees

bearophile bearophileHUGS at lycos.com
Mon Nov 25 16:28:33 PST 2013


Bartosz Milewski has written the second article about immutable 
data structures in C++11, this time about Red-Black trees:
http://bartoszmilewski.com/2013/11/25/functional-data-structures-in-c-trees/

The C++11 code with few small changes (like using "enum class" 
instead of "enum"):
http://codepad.org/AEVVnfSc

D has GC and transitive immutability, so I have tried a D 
translation, a first draft:
http://dpaste.dzfl.pl/a48452af3

In the D code there are some problems with C++ lines as:
return RBTree(Color::R, RBTree(), x, RBTree());

And I don't know if this is public:
     Color rootColor() const {

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list