Class OrderedHash
In: lib/ordered_hash.rb
Parent: Hash

OrderedHash

Version

 1.2006.05.23 (change of the first number means Big Change)

Description

 Hash which preserves order of added items (like PHP array).

Usage

(see examples directory under the ruby gems root directory)

 require 'rubygems'
 require 'ordered_hash'

 hsh = OrderedHash.new
 hsh['z'] = 1
 hsh['a'] = 2
 hsh['c'] = 3
 p hsh.keys     # ['z','a','c']

Source

simplypowerful.1984.cz/goodlibs/1.2006.05.23

Author

 jan molic (/mig/at_sign/1984/dot/cz/)

Thanks to

 Andrew Johnson for his suggestions and fixes of Hash[], merge, to_a, inspect and shift
 Desmond Dsouza for == fixes

Licence

 You can redistribute it and/or modify it under the same terms of Ruby's license;
 either the dual license version in 2003, or any later version.

Methods

==   []   []=   clear   delete   delete_if   each   each_key   each_pair   each_value   first   inspect   invert   keys   last   merge   merge!   new   pop   push   reject   reject!   replace   select   shift   store   store_only   to_a   to_s   unshift   update   values  

External Aliases

store -> orig_store

Attributes

order  [RW] 

Public Class methods

Public Instance methods

[]=(a,b)

Alias for store

each_pair()

Alias for each

merge!(hsh2)

Alias for update

[Validate]