NAME

Iterator::Flex::Zip - Zip Iterator Class

VERSION

version 0.28

METHODS

new

$iterator = Iterator::Flex::Zip->new( $iterable1, $iterable2, ..., ?\%pars );
$iterator = Iterator::Flex::Zip->new( key1 => $iterable1,
                            key2 => iterable2, ..., ?\%pars );

Returns an iterator which returns, as a single element, the next element from each of the passed iterables. By default the iterator is exhausted if any of the input iterables is exhausted; this behavior may be changed via the "on_exhaustion" parameter.

If the input is a list of iterables, the returned iterator will return an array reference containing an element from each iterable.

If the input is a list of key, iterable pairs, it will return a hash reference.

The iterables are converted into iterators via "to_iterator" in Iterator::Flex::Factory if required.

In addition to the standard signal parameters, the optional %pars hash may contain the following:

on_exhaustion

This specifies what the iterator does when any of the input iterators is exhausted early. It can take the following values:

truncate

The Zip iterator will signal exhaustion when any of the input iterators is exhausted. This is the default behavior.

throw

The Zip iterator will throw an instance of the iterator::Flex::Failure::Truncated exception class. The object's msg method will contain an array indicating which of the input iterators were exhausted, either the zero-based positions of the iterators in the order they were specified, or, if they were specified with keys, their keys.

a hashref

The hashref provides values to be used for exhausted input iterators until all of the iterators are exhausted. The keys are either the zero-based positions of the iterators in the order they were specified, or, if they were specified with keys, their keys.

If an iterator without a replacement value is exhausted, the Zip iterator will signal exhaustion.

The iterator supports the following capabilities:

next

And optionally (if the iterables support it)

reset

INTERNALS

SUPPORT

Bugs

Please report any bugs or feature requests to bug-iterator-flex@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=Iterator-Flex

Source

Source is available at

https://gitlab.com/djerius/iterator-flex

and may be cloned from

https://gitlab.com/djerius/iterator-flex.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius <djerius@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007