Array-Circular
view release on metacpan or search on metacpan
lib/Array/Circular.pm view on Meta::CPAN
my $number_of_times_been_around = $l->loops
$l->loops(-3);
The loops method keeps track of how many times the array has been
around. Looping forwards increases the loop count. Looping back
decreases it. Sending in a number will set the counter but beware, no
validation is performed on set operations.
=head3 reset
$l->reset
Resets the current index and loop count to 0.
=head4 me
my $internal_store = $l->me
This is the internal store that tracks the current state of the list.
It's intended for internal use only.
=head4 current_and_next / curr_and_next
Convenience method to return current value then proceed next. Same
interface as C<next>.
=head4 current_and_previous / curr_and_prev
Convenience method to return current value then proceed previous. Same
interface as C<previous>.
=head4 peek
Peek n forward (defaults to 1). Take care if you're reliant on calculating
the number of loops as part of this. This Returns the entry for each
without updating the value of C<loops>.
=head4 size
Returns the number of elements in the list.
=head2 GOTCHAS
Some array modification operations are supported. For example splice,
push and pop operations are untested. If you mutate the array you may
consider using C<reset>, C<loops> and C<index> to fix up the effects
of your mutation.
=head2 IMPLEMENTATION NOTES
This module is implemented as an inside out object.
=head2 SEE ALSO
L<Array::Iterator::Circular> provides similar functionality but it
does not support C<previous>. L<Array::Iterator> contains a survey of
various similar modules.
=head2 TODO
Not thread safe. See implementation of L<Hash::MultiValue> for
implementation of thread safety. Alternatively use
L<Hash::Util::FieldHash> or L<Hash::Util::FieldHash::Compat>.
=head2 AUTHOR COPYRIGHT AND LICENSE
Copyright 2018 Kieren Diment L<zarquon@cpan.org>. This software can
be redistributed under the same terms as perl itself.
=cut
( run in 2.806 seconds using v1.01-cache-2.11-cpan-524268b4103 )