NAME
EO::Hash - hash type collection
SYNOPSIS
use EO::Hash;
$hash = EO::Hash->new();
$hash->at( 'foo', 'bar' );
my $thing = $hash->at( 'foo' );
print "ok\n" if $thing->has( 'foo' );
$thing->delete( 'foo' );
my $keys = $hash->keys;
my $vals = $hash->values;
my $count = $hash->count;
my %hash = %$hash;
DESCRIPTION
EO::Hash is an OO wrapper around Perl's hash type. Objects of the hash class will act as a normal hash outside of any class that does not have an 'EO::' prefix.
INHERITANCE
EO::Hash inherits from EO::Collection.
CONSTRUCTOR
EO::Hash provides the following constructors beyond those that the parent class provides:
METHODS
- has( KEY )
-
Returns true if the key exists inside the hash
- add( EO::Pair )
-
Adds a pair to the hash.
- pair_for( KEY )
-
Returns an EO::Pair object for the key value pair at KEY.
- do( CODE )
-
Runs the coderef CODE for each pair in the EO::Hash object. It passes CODE the EO::Pair object as both its first argument and as $_. CODE must return a pair object. The do method returns an EO::Hash which has all the pairs that are returned from CODE.
- select( CODE )
-
Runs the coderef CODE for each pair in the EO::Hash object. It passes CODE the EO::Pair object as both its first argument and as $_. If the result of running the code is true, then the pair is added to a new EO::Hash object which is returned.
- at( KEY [, VALUE] )
-
Gets and sets key value pairs. KEY should always be a string. If provided VALUE will be placed in the EO::Hash object at the key KEY.
- delete( KEY )
-
Deletes a key/value pair, indexed by key, from the EO::Hash object.
- count
-
Returns an integer representing the number of key/value pairs in the EO::Hash object.
- iterator
-
Returns a Perl hash.
- keys
-
In scalar context returns an EO::Array object of keys in the EO::Hash. In list context it returns a Perl array of keys in the EO::Hash.
- values
-
In scalar context returns an EO::Array object of values in the EO::Hash. In list context it returns a Perl array of values in the EO::Hash.
SEE ALSO
EO::Collection, EO::Array
AUTHOR
James A. Duncan <jduncan@fotango.com>
COPYRIGHT
Copyright 2003 Fotango Ltd. All Rights Reserved.
This module is released under the same terms as Perl itself.