www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Associative Arrays

reply Ant^2i <Ant^2i_member pathlink.com> writes:
Are associative arrays implemented with hashtables?
Or does them use some tree structure?
Jun 11 2005
next sibling parent "Walter" <newshound digitalmars.com> writes:
"Ant^2i" <Ant^2i_member pathlink.com> wrote in message
news:d8fsdg$1ed6$1 digitaldaemon.com...
 Are associative arrays implemented with hashtables?
 Or does them use some tree structure?

Both. The source is in phobos/internal/aaA.d
Jun 11 2005
prev sibling parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Ant^2i" <Ant^2i_member pathlink.com> wrote in message 
news:d8fsdg$1ed6$1 digitaldaemon.com...
 Are associative arrays implemented with hashtables?
 Or does them use some tree structure?

When you say tree structure - do you mean a balanced tree like STL's map? The builtin AA uses trees but they aren't balanced expicitly. If you want a sorted associative array then check out one of the container template libraries like MinTL, DTL or Indigo. Since I wrote MinTL I know it has a sorted AA but I don't know all that much about the others.
Jun 12 2005