iterS3 | R Documentation |
An Iterator
is an object that allows to iterate over
sequences. It implements next_iter()
and get_value()
to iterate and retrieve the
value of the sequence it is associated with.
For documentation of the methods see Iterator.
iter(x, ...) ## S3 method for class 'Container' iter(x, ...) ## Default S3 method: iter(x, ...) is.iterator(x) is.iterable(x) begin(it) get_value(it) get_next(it) has_next(it) has_value(it) pos(it) next_iter(it) reset_iter(it) ## S3 method for class 'Iterator' length(x)
x |
an object of class Iterable or any other |
... |
other parameters passed to or from methods |
it |
|
length
returns the number of elements that can be iterated over.
For the class documentation see Iterator.
# Numeric Vector v = 1:3 it = iter(v) it try(it$get_value()) # iterator does not point at a value has_value(it) has_next(it) next_iter(it) get_value(it) get_next(it) get_next(it) it has_next(it) begin(it) get_value(it) reset_iter(it) # Works on copy of Container co = container(1, 2, 3) it = iter(co) get_next(it) ref_discard(co, 2) co it get_next(it) ref_clear(co) co it get_next(it) begin(it)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.