From: Kent Sibilev Date: 2005-09-27T03:33:59+09:00 Subject: Re: Is there a hash-like class that maintains insertion order You can also check out the red-black tree implementation at http://raa.ruby-lang.org/project/ruby-rbtree/ Kent. On Mon, 2005-09-26 at 11:21 +0900, Bob Hutchison wrote: > Hi, > > Is there a Hash-like class that maintains insertion order and, > ideally, allows 'retrieval' by either key or index? I googled around > for this but can't seem to hit on a query string that is useful. > > In a perfect implementation I'd be able to do something like: > > hash = HashMaintainingInsertionOrder.new > hash["a"] = "aaa" > hash["b"] = "bbb" > hash["c"] = "ccc" > > assert_equal(hash["a"], hash[0]) > assert_equal(hash["b"], hash[1]) > assert_equal(hash["c"], hash[2]) > > Thanks, > Bob > > ---- > Bob Hutchison -- blogs at > Recursive Design Inc. -- > Raconteur -- > > > >