dcollections version 0.02

Steven Schveighoffer schveiguy at yahoo.com
Tue Aug 5 08:51:10 PDT 2008


"dsimcha" wrote
> Nice work.  This brings to the table a lot of stuff that I really felt was 
> missing
> in D2.  One quick question, though.  Given that associative arrays are 
> built-in
> and implemented as hash tables, are there any tradeoffs dcollections makes
> differently than the builtins that would make me choose one over the 
> other?  As a
> hypothetical example, is the dcollections HashMap more tuned for space at 
> the
> expense of speed, or vice-versa than the builtin?

Two main reasons you might choose HashMap over the builtin.

1. customizable.  You can customize down to the hash implementation.
2. api.  HashMap offers a lot more features than the builtin, such as 
removal while traversing, or keeping a cursor to a specific element for 
later use and possible removal.

The ArrayList only really exists to implement the list interface as an 
array-style container.  I made it really easy to switch between using the 
builtin array type and the ArrayList.

There is the performance benefit, but you must be using Tango (and therefore 
D1), as Phobos does not provide a necessary GC function needed for the 
custom allocator.  At that point, you can just use the Tango containers 
(although there are some features that the tango containers don't have).

On a side note, have you used dcollections with D2?  I haven't tested it. 
And it's not const-ified.

-Steve 




More information about the Digitalmars-d-announce mailing list