NAME

Module::Generic::Iterator::Element - An Array Iterator Element Object Class

SYNOPSIS

my $i = Module::Generic::Iterator->new( [qw( Joe John Mary )] );
# or also:
my $a = Module::Generic::Array->new( [qw( Joe John Mary )] );
my $i = $a->iterator;
while( $i->has_next )
{
    my $elem = $i->next;
    my $value = $elem->value;
    # Get the next element relative to our element
    printf( "Next value is: %s at offset %d\n", $elem->next, $elem->next->pos  );
}

VERSION

v0.1.0

DESCRIPTION

This is an object class for Module::Generic::Iterator::Element objects as returned by various methods of Module::Generic::Iterator.

METHODS

new

Provided with an array value (whatever that may be) and an optional hash reference of parameters, and this will create a new iterator and return it.

Typical parameters are:

parent

This is the Module::Generic::Iterator object and it is required.

has_next

Returns true if there is another item after the current one.

has_prev

Returns true if there is another item before the current one.

next

Returns the next Module::Generic::Iterator::Element object relative to this object or undef if there are no more element.

parent

Sets or gets a Module::Generic::Iterator object as the parent object for this array element.

pos

Returns the position of the object inside the parent array. This is read-only and returns an integer.

prev

Returns the previous Module::Generic::Iterator::Element object relative to this object or undef if there are no more previous element.

value

Return the value of the Module::Generic::Iterator::Element object, whatever that may be.

SERIALISATION

Serialisation by CBOR, Sereal and Storable::Improved (or the legacy Storable) is supported by this package. To that effect, the following subroutines are implemented: FREEZE, THAW, STORABLE_freeze and STORABLE_thaw

SEE ALSO

Module::Generic::Iterator::Element, Module::Generic::Array

AUTHOR

Jacques Deguest <jack@deguest.jp>

COPYRIGHT & LICENSE

Copyright (c) 2000-2020 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.