Array::Stream::Transactional - Transactional array wrapper
SYNOPSIS
use Array::Stream::Transactional;
my $stream = Array::Stream::Transactional->new([1..100]);
$stream->commit;
while($stream->has_more) {
if($stream->next == 50 && !$reverted) {
$stream->rollback;
$reverted = 1;
}
print $stream->current, "\n";
}
DESCRIPTION
Array::Stream::Transactional is a Perl extension for wrapping an array and having it pose as a stream. The streams current position can be commited and rollbacked at any time.
CONSTRUCTOR
- new ( ARRAYREF )
-
Creates an
Array::Stream::Transactional
. Wrapps the passed array reference. Position is set to 0, current is set the first element in ARRAYREF, previous is set to undef and the transaction stack is empty.
METHODS
- next ( )
-
Get the next element from the stream and increment the position in the current transaction.
- current ( )
-
Get the current element read from the stream in the current transaction.
- previous ( )
-
Get the previous element read from the stream in the current transaction.
- pos ( )
-
Return the current position in the stream.
- length ( )
-
Return the length of the wrapped array
- has_more ( )
-
Return true if there are more elements in the stream, false otherwise.
- commit ( )
-
Push the current position, element and previous element on the transaction stack.
- rollback ( )
-
Rollback the current transaction by reseting the stream position, current and previous object. The transaction will be removed from the transaction stack so that next rollback will rollback to the commit previous to the commit that created the rollbacked transaction.
AUTHOR
Claes Jacobsson, claesjac@cpan.org
COPYRIGHT AND LICENSE
Copyright 2004 by Claes Jacobsson
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 72:
=pod directives shouldn't be over one line long! Ignoring all 2 lines of content