Data-ArrayList
view release on metacpan or search on metacpan
Returns the number of elements in this list.
clone
my $copy = $dal->clone;
Returns a shallow copy of this instance. The elements themselves are not
copied.
toArray
my @elements = $dal->toArray;
Returns an array containing all of the elements in this list in proper
sequence (from first to last element).
The returned array will be "safe" in that no references to it are
maintained by this list. (In other words, this method must allocate a
new array). The caller is thus free to modify the returned array.
Note: The *safeness* of the copy is provided by Data::Clone. Please make
sure that all blessed objects implement "clone" to support deep cloning.
set
$dal->set( $index, $value );
Replaces the element at the specified position in this list with the
specified element.
Returns the element previously at the specified position.
ensureCapacity
$dal->ensureCapacity( $minCapacity );
Increases the capacity of this instance, if necessary, to ensure that it
can hold at least the number of elements specified by the minimum
capacity argument.
Note: This method is not supported by objects returned by "subList".
remove
$dal->remove( $index );
Removes the element at the specified position in this list. Shifts any
subsequent elements to the left (subtracts one from their indices).
Returns the element that was removed from the list.
listIterator
my $li = $dal->listIterator( $initialPosition );
Returns a list iterator (Data::ArrayList::ListIterator) of the elements
in this list (in proper sequence), starting at the specified position
(*default is 0*) in this list. The specified index indicates the first
element that would be returned by an initial call to next. An initial
call to previous would return the element with the specified index minus
one.
Iterator will die with "ConcurrentModification" if the parent list has
been *structurally modified*. Structural modifications are those that
change the size of the list, or otherwise perturb it in such a fashion
that iterations in progress may yield incorrect results.
subList
my $sl = $dal->subList( $rangeFrom, $rangeTo );
Returns a view of the portion of this list between the specified
"rangeFrom", inclusive, and "rangeTo", exclusive. (If "rangeFrom" and
"rangeTo" are equal, the returned list is empty.) The returned list is
backed by this list, so non-structural changes in the returned list are
reflected in this list, and vice-versa. The returned list supports all
of the optional list operations supported by this list.
This method eliminates the need for explicit range operations (of the
sort that commonly exist for arrays). Any operation that expects a list
can be used as a range operation by passing a subList view instead of a
whole list. For example, the following idiom removes a range of elements
from a list:
$dal->subList($from, $to)->clear();
Returned sublist is a subclass of Data::ArrayList and supports all of
its methods (except the "ensureCapacity").
Sublists could be nested, as in:
$dal->subList( 1, 100 )->subList( 20, 20 );
SEE ALSO
* perlfunc
* List::MoreUtils
* Data::Clone
* <http://download.oracle.com/javase/6/docs/api/java/util/ArrayList.ht
ml>
AUTHOR
Alex J. G. BurzyÅski <ajgb@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Alex J. G. BurzyÅski
<ajgb@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
( run in 0.524 second using v1.01-cache-2.11-cpan-f03e8824b8d )