NAME

EO::Array - array type collection

SYNOPSIS

use EO::Array;

$array = EO::Array->new();
$array->at( 0, 'bar' );

my $thing = $array->at( 0 );
$thing->delete( 0 );

$array->push('value');
my $value = $array->shift( $array->unshift( $array->pop() ) );

my $count = $array->count;

my @array = @$array;

DESCRIPTION

EO::Array is an OO wrapper around Perl's array type. It will act both as an object and as an array reference.

INHERITANCE

EO::Array inherits from EO::Collection.

CONSTRUCTOR

EO::Array provides the following constructors beyond those that the parent class provides:

new_with_array( ARRAYREF )

Prepares a EO::Array object that has all the elements contained in ARRAYREF.

METHODS

do( CODE )

The do method calls CODE with each of the elements of your array. It sets both $_ and the first argument passed to CODE as the element. The return value of CODE is added to a new array that is returned by the do method.

select( CODE )

The select method calls CODE with each of the elements of your array, it works in a similar way to the do method. The only difference is that if CODE returns a true value, then the element is added to a new array which is returned from the select method.

at( KEY [, VALUE] )

Gets and sets key value pairs. KEY should always be an integer. If provided VALUE will be placed in the EO::Array object at the index KEY.

delete( KEY )

Deletes a key/value pair, indexed by key, from the EO::Array object.

count

Returns an integer representing the number of key/value pairs in the EO::Array object.

iterator

Returns a Perl array.

pop

Removes an item from the end of the EO::Array and returns it

push( LIST )

Adds items on to the end of the EO::Array object

shift

Removes an item from the beginning of the EO::Array

unshift( LIST )

Adds items on to the beginning of the EO::Array object

splice( [OFFSET [, LENGTH [, LIST]]] )

Splice an array (see perldoc -f splice for more information).

SEE ALSO

EO::Collection, EO::Hash

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.