From: Nikolai Weibull Date: 2004-12-02T23:37:34+09:00 Subject: Re: ordered hash ? * itsme213 [Dec 02, 2004 14:00]: > Is there a pure-ruby ordered hash? I'm looking for something that will > preserve the order in which key/value pairs were entered. The one on > RAA is buggy http://raa.ruby-lang.org/project/orderedhash/ Having an ordered Hash is like saying that arrays should be indexed by strings--it's simply not what they are meant to be. My RDSL library (http://rdsly.rubyforge.org/) contains an implementation of the Treap ADT. It works like a Hash, but preserves order. It is implemented much like a Tree but with Heap-like abilities--hence the name. Anyway, the items are ordered, not by insertion but by comparison. It does not use a two-level scheme like OrderedHash seems to use, so there's no wasted memory on keeping ordering information. Also, benchmarks have shown that it works very fast, even though it's purely ruby. If a Treap isn't your style, RDSL also includes a SkipList implementation, that has similar capabilities to that of a Treap; it's yet another sorted ADT. Please, if you haven't already commited to some solution, give RDSL a try. It needs some testing. I'm going to get back to working on it when I get time, but until then, some love from other users wouldn't hurt. End of plug. Thanks, nikolai -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}