[Issue 10009] foreach_reverse and AA.byKey/byValue

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 25 10:08:28 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=10009

--- Comment #15 from bearophile_hugs at eml.cc ---
(In reply to yebblies from comment #14)

> I'd love for the built-in AAs to use a linked hash map and guarantee
> iteration in insertion order...  It does have a performance hit on insertion
> and deletion, but it is a really nice property for a default AA that isn't
> super-optimized for any particular use case.

In my opinion built-in data structures should be first of all very flexible
(and keeping the insertion order is a guaranteed that makes them more useful).
But in engineering as usual you have trade-offs. So how much is going to
increase the memory and how much is going to decrease the performance with that
added feature?

In Python the built-in dict is fast, and there is an ordered dict in its
standard library:
https://docs.python.org/2/library/collections.html#collections.OrderedDict

With a druntime function added I think you can implement ordered AAs for Phobos
(based on the built-in ones) in an efficient way and a small amount of code,
see Issue 10733

--


More information about the Digitalmars-d-bugs mailing list