On Thu, 24 Aug 2006, Pit Capitain wrote:

>
> Sven, regarding the "HistoryHash" part of your post:
>
> In order to replace the standard Hash with a "better" Hash, there should be a 
> clear agreement on its desired behaviour. I don't think this agreement has 
> been achieved yet. What should be the result of the following code?
>
>  hh = HistoryHash.new
>  hh[:one] = 1
>  hh[:two] = 2
>  hh[:one] = 3
>  hh.each do |k, v| p k end
>
> Should it be
>
>  :one
>  :two
>
> or
>
>  :two
>  :one
>
> Why should it be the one or the other?

   harp:~ > cat a.rb
   require 'rubygems'
   require 'alib'
   HistoryHash = Alib::OrderedHash

   hh = HistoryHash.new
   hh[:one] = 1
   hh[:two] = 2
   hh[:one] = 3
   hh.each do |k, v| p k end


   harp:~ > ruby a.rb
   :one
   :two


because it's based on __insertion__ order.  if one wants a new insertion use:

   harp:~ > cat a.rb
   require 'rubygems'
   require 'alib'
   HistoryHash = Alib::OrderedHash

   hh = HistoryHash.new

   hh[:one] = 1
   hh[:two] = 2
   hh[:three] = 3

   hh.delete :two
   hh[:two] = 2

   hh.each do |k, v| p k end


   harp:~ > ruby a.rb
   :one
   :three
   :two


of course that's my 2 cts.

-a
-- 
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama