RIterator<A> class
abstract
A single-use, forward-only iterator over elements of type A.
RIterator is the traversal primitive for all ribs collections. Callers advance it by checking hasNext and then calling next. Each element is produced exactly once — the iterator cannot be reset.
Create instances with the static factory methods:
- RIterator.empty — an iterator that immediately reports
hasNext == false - RIterator.single — one element
- RIterator.fill —
lencopies of the same element - RIterator.tabulate —
lenelements computed by index - RIterator.fromDart — wrap a Dart Iterator
- RIterator.iterate — infinite sequence
start, f(start), f(f(start)), … - RIterator.unfold — stateful anamorphism that terminates when
freturns None
All transformation methods (map, filter, flatMap, etc.) return lazy iterators — they do not evaluate elements until next is called.
- Mixed-in types
- Available extensions
Constructors
- RIterator()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasNext → bool
-
Whether the iterator has a next element.
no setter
- isEmpty → bool
-
Whether this collection contains no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection contains at least one element.
no setterinherited
- isTraversableAgain → bool
-
Whether this collection can be traversed more than once.
no setterinherited
-
iterator
→ RIterator<
A> -
Returns an RIterator over the elements of this collection.
no setteroverride
- knownSize → int
-
Returns the number of elements in this collection, if that number is
already known. If not, -1 is returned.
no setterinherited
- nonEmpty → bool
-
Whether this collection contains at least one element.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Returns the number of elements in this collection.
no setterinherited
-
toDart
→ Iterator<
A> -
Converts this RIterator to a Dart Iterator.
no setter
Methods
-
collect<
B> (Function1< A, Option< f) → RIterator<B> >B> -
Returns a new collection by applying
fto each element an only keeping results of type Some.override -
collectFirst<
B> (Function1< A, Option< f) → Option<B> >B> -
Applies
fto each element of this collection, returning the first element that results in a Some, if any.inherited -
concat(
RIterableOnce< A> xs) → RIterator<A> -
Returns an iterator that first yields all elements of this iterator, then
all elements of
xs. -
copyToArray(
Array< A> xs, [int start = 0, int? n]) → int -
Copies elements into
xsstarting atstart, writing at mostnelements (or all remaining capacity whennis omitted).inherited -
corresponds<
B> (covariant RIterable< B> that, Function2<A, B, bool> p) → bool -
Returns true if this collection has the same size as
thatand each corresponding element from this andthatsatisfies the given predicatep.inherited -
count(
Function1< A, bool> p) → int -
Return the number of elements in this collection that satisfy the given
predicate.
inherited
-
distinct<
B> (Function1< A, B> f) → RIterator<A> - Returns an iterator that skips duplicate elements, keeping first occurrence.
-
distinctBy<
B> (Function1< A, B> f) → RIterator<A> -
Returns an iterator that skips elements whose key
f(elem)has already been seen, keeping the first occurrence of each key. -
drop(
int n) → RIterator< A> -
Returns a new collection with the first
nelements removed.override -
dropWhile(
Function1< A, bool> p) → RIterator<A> -
Returns a new collection with leading elements satisfying
premoved.override -
exists(
Function1< A, bool> p) → bool -
Returns true if any element of this collection satisfies the given
predicate, false if no elements satisfy it.
inherited
-
filter(
Function1< A, bool> p) → RIterator<A> -
Returns a new collection containing only elements that satisfy
p.override -
filterNot(
Function1< A, bool> p) → RIterator<A> -
Returns a new collection containing only elements that do not
satisfy
p.override -
find(
Function1< A, bool> p) → Option<A> -
Returns the first element from this collection that satisfies the given
predicate
p. If no element satisfiesp, None is returned.inherited -
flatMap<
B> (covariant Function1< A, RIterableOnce< f) → RIterator<B> >B> -
Returns a new collection by applying
fto each element and concatenating the results.override -
foldLeft<
B> (B z, Function2< B, A, B> op) → B -
Returns a summary value by applying
opto all elements of this collection, moving from left to right. The fold uses a seed value ofz.inherited -
foldRight<
B> (B z, Function2< A, B, B> op) → B -
Returns a summary value by applying
opto all elements of this collection, moving from right to left. The fold uses a seed value ofz.inherited -
forall(
Function1< A, bool> p) → bool -
Returns true if all elements of this collection satisfy the given
predicate, false if any elements do not.
inherited
-
foreach<
U> (Function1< A, U> f) → void -
Applies
fto each element of this collection, discarding any resulting values.inherited -
grouped(
int size) → RIterator< RSeq< A> > -
Returns an iterator of non-overlapping groups of
sizeconsecutive elements. -
indexOf(
A elem, [int from = 0]) → Option< int> -
Returns
Some(index)of the first occurrence ofelemat or afterfrom, or None if not found. -
indexWhere(
Function1< A, bool> p, [int from = 0]) → Option<int> -
Returns
Some(index)of the first element satisfyingpat or afterfrom, or None if no such element exists. -
map<
B> (Function1< A, B> f) → RIterator<B> -
Returns a new collection by applying
fto each element.override -
maxByOption<
B> (Function1< A, B> f, Order<B> order) → Option<A> -
Finds the largest element in this collection by applying
fto each element and using the given Order to find the greatest.inherited -
maxOption(
Order< A> order) → Option<A> -
Finds the largest element in this collection according to the given
Order.
inherited
-
minByOption<
B> (Function1< A, B> f, Order<B> order) → Option<A> -
Finds the smallest element in this collection by applying
fto each element and using the given Order to find the greatest.inherited -
minOption(
Order< A> order) → Option<A> -
Finds the largest element in this collection according to the given
Order.
inherited
-
mkString(
{String? start, String? sep, String? end}) → String -
Returns a String by using each elements toString(), adding
sepbetween each element. Ifstartis defined, it will be prepended to the resulting string. Ifendis defined, it will be appended to the resulting string.inherited -
next(
) → A - Returns the next element, advancing the iterator.
-
noSuchElement(
[String? message]) → Never -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padTo(
int len, A elem) → RIterator< A> -
Returns an iterator that yields all elements of this iterator and then
elemrepeated until the total count reacheslen. -
patch(
int from, RIterator< A> patchElems, int replaced) → RIterator<A> -
Returns an iterator that replaces
replacedelements starting at positionfromwith the elements ofpatchElems. -
product(
) → double -
Available on RIterableOnce<
Returns the product of all elements in this listdouble> , provided by the RIterableDoubleOps extension -
product(
) → int -
Available on RIterableOnce<
Returns the product of all elements in this listint> , provided by the RIterableIntOps extension -
reduce(
Function2< A, A, A> op) → A -
Reduces this collection to a single value by applying
opleft to right.inherited -
reduceLeft(
Function2< A, A, A> op) → A -
Reduces from left to right. Throws if empty.
inherited
-
reduceLeftOption(
Function2< A, A, A> op) → Option<A> -
Returns a summary values of all elements of this collection by applying
fto each element, moving left to right.inherited -
reduceOption(
Function2< A, A, A> op) → Option<A> -
Returns a summary values of all elements of this collection by applying
fto each element, moving left to right.inherited -
reduceRight(
Function2< A, A, A> op) → A -
Reduces from right to left. Throws if empty.
inherited
-
reduceRightOption(
Function2< A, A, A> op) → Option<A> -
Returns a summary values of all elements of this collection by applying
fto each element, moving right to left.inherited -
sameElements(
RIterableOnce< A> that) → bool -
Returns
trueif this iterator andthatproduce the same elements in the same order and both exhaust at the same time. -
scan<
B> (B z, Function2< B, A, B> op) → RIterableOnce<B> -
Alias for scanLeft.
inherited
-
scanLeft<
B> (B z, Function2< B, A, B> op) → RIterator<B> -
Returns a new collection of running totals starting with
z.override -
slice(
int from, int until) → RIterator< A> -
Returns a new collection containing elements in the range
[from, until).override -
sliceIterator(
int from, int until) → RIterator< A> -
sliding(
int size, [int step = 1]) → RIterator< RSeq< A> > -
Returns an iterator of overlapping windows of
sizeelements, advancing bystepelements between windows. -
span(
Function1< A, bool> p) → (RIterator<A> , RIterator<A> ) -
Returns two collections: elements before and starting from the first
element that does not satisfy
p.override -
splitAt(
int n) → (RIterableOnce< A> , RIterableOnce<A> ) -
Returns two collections: the first
nelements and the remainder.inherited -
sum(
) → double -
Available on RIterableOnce<
Returns the sum of all elements in this listdouble> , provided by the RIterableDoubleOps extension -
sum(
) → int -
Available on RIterableOnce<
Returns the sum of all elements in this listint> , provided by the RIterableIntOps extension -
take(
int n) → RIterator< A> -
Returns a new collection containing only the first
nelements.override -
takeWhile(
Function1< A, bool> p) → RIterator<A> -
Returns a new collection of leading elements that satisfy
p.override -
tapEach<
U> (Function1< A, U> f) → RIterableOnce<A> -
Applies
fto each element in this collection, discarding any results and returns this collection.inherited -
toIList(
) → IList< A> -
Returns an IList with the same elements as this collection.
inherited
-
toIndexedSeq(
) → IndexedSeq< A> -
Returns an IndexedSeq with the same elements as this collection.
inherited
-
toISet(
) → ISet< A> -
Returns an ISet with the same elements as this collection, duplicates
removed.
inherited
-
toIVector(
) → IVector< A> -
Returns an IVector with the same elements as this collection.
inherited
-
toList(
{bool growable = true}) → List< A> -
Returns a new List with the same elements as this collection.
inherited
-
toSeq(
) → RSeq< A> -
Returns a RSeq with the same elements as this collection.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
zip<
B> (RIterableOnce< B> that) → RIterator<(A, B)> - Returns an iterator of pairs, stopping when either side is exhausted.
-
zipAll<
B> (RIterableOnce< B> that, A thisElem, B thatElem) → RIterator<(A, B)> -
Returns an iterator of pairs, padding the shorter side with
thisElemorthatElemuntil both sides are exhausted. -
zipWithIndex(
) → RIterator< (A, int)> -
Returns an iterator of
(element, index)pairs.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
empty<
A> () → RIterator< A> -
Returns an iterator that immediately reports
hasNext == false. -
fill<
A> (int len, A elem) → RIterator< A> -
Returns an iterator that yields
elemexactlylentimes. -
fromDart<
A> (Iterator< A> it) → RIterator<A> - Wraps a Dart Iterator in an RIterator.
-
iterate<
A> (A start, Function1< A, A> f) → RIterator<A> -
Returns an infinite iterator producing
start, f(start), f(f(start)), …. -
single<
A> (A a) → RIterator< A> -
Returns an iterator that yields
aexactly once. -
tabulate<
A> (int len, Function1< int, A> f) → RIterator<A> -
Returns an iterator of length
lenwhere elementiisf(i). -
unfold<
A, S> (S initial, Function1< S, Option< f) → RIterator<(A, S)> >A> - Returns an iterator produced by an anamorphism.