Iterator::RoundRobin - The great new Iterator::RoundRobin!
Why? Because its Great! And New!
use Iterator::RoundRobin; my $rr = Iterator::RoundRobin->new( [qw/usera-1 usera-2 usera-3/], [qw/userb-1 userb-2 userb-3/] ); while (my $user = $rr->next()) { print "User $user.\n"; }
The new method returns an instantiated Iterator::RoundRobin object. This method does require at least one or more array refs to be passed in. It will fail (ungracefully) if those requirements are not met.
The next method returns the next item in the list. It does very little voodoo to determine where it gets the thing to return. It handles uneven lists and multiple lists fairly well.
This method is use internally to determine if there is anything left to return.
This method is used internally to rebuild the index when a given list is empty. Please don't call this outside of the object.
This module keeps an internal list of items that have been marked 'completed' which may be a memory hog if you let it. To disable this tracking set the internal variable 'track_completed' as false after object creation.
my $iter = Iterator::RoundRobin->new( ... ); $iter->{'track_completed'} = 0;
Nick Gerakines, <nick at gerakines.net>
<nick at gerakines.net>
Please report any bugs or feature requests to the author.
This module was inspired by Data::RoundRobin. Thanks.
Copyright 2006 Nick Gerakines, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Iterator::RoundRobin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Iterator::RoundRobin
CPAN shell
perl -MCPAN -e shell install Iterator::RoundRobin
For more information on module installation, please visit the detailed CPAN module installation guide.