From: Florian Gilcher Date: 2011-07-16T22:30:46+09:00 Subject: Re: does OrderedHash exist? On Jul 16, 2011, at 2:32 PM, Robert Klemme wrote: > On Sat, Jul 16, 2011 at 9:34 AM, Oren Shani wrote: >> I created a class called, HashArray which implements a pretty >> straightforward Hash with order object. Content can be added, deleted, >> reordered, etc, and then there is the as_array method that enables using >> the object as an array. > > I'm curious how you manage to keep the data structure ordered and keep > access time O(1). It surely is O(1) since it's called _Hash_Array, > isn't it? > > Kind regards > > robert Not speaking for the OP, but the naive solution by keeping book of key ordering in an Array for ordered access (mostly iteration) and going straight for a plain Hash for storage and unordered access already fulfills that. Non-trivial insertion would suffer, because it has to reorganize the keys. Regards, Florian