Does D have "structural sharing" of immutable collections?

Stewart Gordon smjg_1998 at yahoo.com
Wed May 23 11:38:57 PDT 2012


On 23/05/2012 16:05, Roman D. Boiko wrote:
<snip>
> I need some immutable collections for my D Compiler Tools project, namely linked list,
> red-black tree, and possibly some others.
<snip>

What's the point of an immutable red-black tree?

The whole point of a red-black tree is to facilitate fast dynamic addition, removal and 
lookup of elements.

When the tree is immutable, only lookup speed is of any real relevance, so you might as 
well create a perfectly balanced binary tree.  Or even better, an array.

Stewart.


More information about the Digitalmars-d mailing list