Subject: | A straight up iterator would be nice |
The double loop is tedious in most cases. However, if I want to collapse my iteration to a
single loop, I either have to write a custom iterator like:
sub iterator {
my $stream = shift;
my $block = [];
return sub { $block = $s->next unless @$block; shift @$block };
}
my $iter = iterator($stream);
while (my $obj = $iter->()) {
# do something...
}
Or consume the whole list using all(). I'd prefer one at a time as an option.
Seems like something like this iterator sub should be part of the interface. This wouldn't be a
problem except that Data::Bulk::Stream is the de facto iterator of KiokuDB, which I'm
experimenting with at the moment. It seems silly for me to write the utility subroutine in
addition to the iterator class, when this is really a function of the iterator class.