
Array - a complete array class

use Class::Maker::Examples::Array;
Array->new( array => [1..100] );
# standard
$a->shift;
$a->push( qw/ 1 2 3 4 / );
$a->pop;
$a->unshift( qw/ 5 6 7 / );
$a->reset;
$a->join( ', ' );
# extended
$a->count;
$a->get;
$a->pick( 4 );
$a->union( 100..500 );
$a->intersection( 50..100 );
$a->diff( 50..100 );
$a->rand;
$a->sort;
$a->totext;
$a->sum;
$a->unique;
$a->permute;
print "same" if $a->eq( $other );

This an object-oriented array class, which uses a method-oriented interface.

Mostly they have the similar syntax as the native perl functions (use "perldoc -f"). If not they are documented below, otherwise a simple example is given.
Returns the number of elements (same as @arry in scalar context).
Resets the array to an empty array.
Returns the backend array.
Returns every 'step' (default: 2) element.
Returns the union of two arrays (Array object is returned).
Returns the intersection of the two arrays (Array object is returned).
Returns the diff of the two arrays (Array object is returned).

None by default.

Because most methods return Array objects itself, the can be easily further treated with Array methods. Here a rather useless, but informative example.
use Class::Maker::Examples::Array;
my $a = Array->new( array => [1..70] );
my $b = Array->new( array => [50..100] );
$a->intersection( $b )->pick( 4 )->join( ', ' );

Murat Uenalan, muenalan@cpan.org
