From: Robert Dober Date: 2006-08-21T20:45:37+09:00 Subject: Re: Why Does Hash Apparently Reorder Its Internal Representation And Other Associated Ponderings ------=_Part_38315_15723811.1156160735724 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 8/21/06, Yukihiro Matsumoto wrote: > > Hi, > > In message "Re: Why Does Hash Apparently Reorder Its Internal > Representation And Other Associated Ponderings" > on Mon, 21 Aug 2006 19:26:10 +0900, "Robert Dober" < > robert.dober@gmail.com> writes: > > |I am just dreaming: > | > |ohhhhhh =3D OrderedHash.new { |k1,k2| tell_my_friend_what_order_is(k1, k= 2) > } > | > |class MyOH < OrderedHash > | def key_order(k1, k2) ### Here we could define Mixins for common > key > |orders > | > |And would asking for having two like the following be too much? > > I think it's not just "ordered" but "sorted". Sorry if I was unclear - just dreaming U know. My naming is bad, usually, often, always? So I was just wondering if an OrderedHash would just define the order and sorting would be done when necessary. A SortedHash would keep track of the keys in a sorted way and sorted access would be fast. To express better what I had in mind was (updated with your naming), expressed in a language I talk better than English, Ruby (1) s =3D SortedHash ... o =3D OrderdHash ... s[:fourty_two] =3D 1764 # internal key order will be updated o[:fourty_two] =3D 1764 # nothing to be done s.each # no presorting needed o.each or o.each_sorted or o.each_ordered # presorting needed Robert (1) That does not mean I cannot talk nonsense in Ruby though ;) matz. > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_38315_15723811.1156160735724--