RAA - orderedhash/1.2006.05.23

orderedhash / 1.2006.05.23

Short description: Hash with preserved order (like Array in php)
Category: Library/Datastructure
Status: stable
Created: 2004-09-17 16:37:45 GMT
Last update: 2006-05-25 18:26:49 GMT
Owner: Jan Molič (Projects of this owner)
Homepage: http://simplypowerful.1984.cz/goodlibs/1.2006.05.23/doc/
Download: http://simplypowerful.1984.cz/goodlibs/1.2006.05.23/GoodLibs-1.2006.05.23.gem
License: Ruby's
Dependency:
None
Description:
OrderedHash merged to GoodLibs and released as GEM.
DeepClone is a part of GoodLibs. The version of GoodLibs is the same for all libraries inside. Change of the first version number means a Big change.

Usage:

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

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

# OrderedHash has useful extensions: push, pop and unshift
  p hsh.push('to_end', 15)  # true, key added
  p hsh.push('to_end', 30)  # false, already - nothing happen
  p hsh.unshift('to_begin', 50)  # true, key added
  p hsh.unshift('to_begin', 60)  # false, already - nothing happen
  p hsh.keys     # ["to_begin", "a", "c", "z", "to_end"]
  p hsh.pop      # ["to_end", 15], if nothing remains, return nil
  p hsh.keys     # ["to_begin", "a", "c", "z"]
  p hsh.shift    # ["to_begin", 30], if nothing remains, return nil
Versions: [1.2006.07.13 (2007-07-05)] [1.2006.05.23 (2006-05-25)] [1.2005.8.16 (2005-08-16)] [1.2005.8.8 (2005-08-15)] [2.0 (2004-12-07)] [2.0-rc1 (2004-11-19)] [1.1 (2004-11-19)] [1.0-r5 (2004-10-11)] [1.0-r4 (2004-10-07)] [0.1 (2004-09-17)]

Edit this project (for project owner)

back to RAA top