i_tee(obj, n)
consumes and buffers the output of a single iterator
obj
so that it can be read by n
independent sub-iterators.
i_tee(obj, n, max = 2^16 - 1, ...)
a list of n
iterators.
an iterable object
the number of iterators to return
The maximum number of values to buffer.
passed along to iteror(obj, ...)
Peter Meilstrup
It works by saving the output of source obj
in a queue, while
each sub-iterator has a "read pointer" indexing into the
queue. Items are dropped from the queue after all sub-iterators
have seen them.
This means that if one sub-iterator falls far behind the others, or
equivalently if one sub-iterator reads far ahead its cohort the
others, the intervening values will be kept in memory. The max
argument gives a limit on how many items will be held. If this
limit is exceeded due to one sub-iterator reading far ahead of the
others, an error will be thrown when that sub-iterator attempts to
read a new value.