SeparatedIterator<T> class

An iterator that yields elements with separators between them.

This iterator wraps an existing iterator and produces elements from the source with a separator value inserted between each pair of adjacent elements.

Type Parameters

  • T - The type of elements being iterated.

Overview

SeparatedIterator is used internally by SeparatedIterable. It maintains state to alternate between source elements and separator values.

Example

final iterator = SeparatedIterator([1, 2, 3].iterator, 0);

while (iterator.moveNext()) {
  print(iterator.current); // Prints: 1, 0, 2, 0, 3
}
Implemented types

Constructors

SeparatedIterator(Iterator<T> _iterator, T _separator)
Creates a separated iterator.

Properties

current → T
The current element.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

moveNext() bool
Advances the iterator to the next element of the iteration.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited