Hi, How about just keep a list of keys as an extra list besides the hash- map? The look-up and iterating without order can be done efficiently without the help of the key list. Iterating with the original order is a little bit expensive but should be acceptable if the hash function is fast.
Certainly, directly store the address of the item in the key list could be more efficient, but only if the hash function is not fast enough to be negligible compared with memory access. On Sep 8, 5:19 am, Conrad <drc...@gmail.com> wrote: > Hi everyone! I have some data that consists of key/value pairs, but > that need to maintain their order, in terms of when they were added to > the list. In most lisps you'd do this with an association list, with a > performance penalty of course if the alist gets too large. > > I was wondering if there's any consensus on how to deal with this type > of data in Clojure yet. Clearly there is a partial alist support, > since you can write things like (seq {:a 1 :b 2}) which essentially > creates an alist- But no lookup function exists for this, I think. > > Alternatively, I suppose it would be possible to create a new type of > map that performs better than an alist but can return items in the > order they were added to the list, if desired (given the way maps are > implemented in Clojure, this info may already be available internally > as part of the implementation I would imagine- Is this exposed > anywhere?) > > Anyway, I was just curious what people's thoughts were on this > issue... > > -Conrad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---