i_tee | R Documentation |
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, ...)
obj |
an iterable object |
n |
the number of iterators to return |
max |
The maximum number of values to buffer. |
... |
passed along to |
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.
a list of n
iterators.
Peter Meilstrup
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.