EO::Hierarchy - hierarchical data structures
my $foo = EO::Hierarchy->new; $foo->at( 'bar', 'baz' ); $foo->add_child( 'frob' ); $foo->at( 'frob' )->at( 'bar' ); ## eq 'baz' ## or my $foo = EO::Hierarchy->new; $foo->delegate( EO::Array->new ); $foo->at( 0, 'baz' ); $foo->add_child( 1 ); $foo->at( 1 )->at( 0 ); ## eq 'baz'
EO::Hierarchy delegates to a collection object to provide heritable data structures. It should be noted that these data structures can appear recursive without being so. This is demonstrable with the following code example:
my $obj = EO::Hierarchy->new; $obj->add_child( 'foo' ); my $recurse = $obj->at('foo'); print "appears recursive" if $recurse == $recurse->at('foo')
Handily the above code sample also displays a mechanism for testing it.
EO::Hierarchy inherits from EO and shares all of its methods. EO::Hierarchy uses the EO::delegate pattern and shares the functionality of it. It provides a default delegation to an EO::Hash object which is constructed as a result of creating an EO::Hierarchy object.
Adds a child into the data structure at the key KEY. The child is also a EO::Hierarchy object that inherits its data from the parent. If you don't want an inheriting child then you should use the at method, as you would with a normal EO::Collection object.
at
James A. Duncan <jduncan@fotango.com>
Copyright 2005 Fotango Ltd. All Rights Reserved.
To install EO, copy and paste the appropriate command in to your terminal.
cpanm
cpanm EO
CPAN shell
perl -MCPAN -e shell install EO
For more information on module installation, please visit the detailed CPAN module installation guide.