From: Robert Klemme Date: 2004-09-04T18:35:50+09:00 Subject: Re: Hashes and ordering "Kristof Bastiaensen" schrieb im Newsbeitrag news:pan.2004.09.04.07.58.02.69935@vleeuwen.org... > On Sat, 04 Sep 2004 12:39:31 +0900, Hal Fulton wrote: > > > Markus wrote: > >> Where are you going with this? There seem to be three unrelated things > >> here: > > > > Well, I have been thinking along the lines of: What if we had a built-in > > ordered indexable collection in Ruby? > > > > What about an association list (Array)? > > [["one", 1], ["two", 2], ["three", 3]].assoc("one") > => ["one", 1] > > You could wrap it in a class to have it behave more like a Hash. Very inefficient if you have many lookups (O(n)). And it doesn't maintain order automatically. The typical and most efficient implementation in the general case of an ordered map is a tree AFAIK. Kind regards robert