From: Hal Fulton Date: 2006-08-13T08:45:54+09:00 Subject: Re: PATCH to make internal Hash class retain order... Brian McCallister wrote: > > On Aug 12, 2006, at 9:55 AM, Thies C. Arntzen wrote: > >> Hi there - >> >> beeing new to ruby (thru rails) and coming from a strong php background > > > > >> * remember the order in which elements have been added to a Hash (at >> the cost of 2 extra pointers in every hash-bucket + 2 extra pointers >> per hash-table) >> * use this order for iterating (st_foreach will use this order) >> * implement a call Hash.order! allows the user to change the internal >> order;-) > > > Nice :-) The better place for discussion hacking on the ruby > interpreter itself is probably ruby-core. > > How difficult would it be to do an OrderedHash data structure as a C > extension instead of in Ruby? Well, if it were another class, then you would lose the order information before you ever got into that class, right? hash = {a=>1, b=>2, c=>3} ordered = OrderedHash.new(hash) # Oops -- too late Hal