Additional top-level class in compilation unit: IteratorModule.
io.vavr.collection.Iterator is a compositional replacement for java.util.Iterator
whose purpose is to iterate once over a sequence of elements.Note
Iterators encapsulate mutable state. They are not meant to be used concurrently by different threads. Do not reuse Iterators, e.g. after passing to io.vavr.collection.List#ofAll(Iterable).
There are two abstract methods: hasNext for checking if there is a next element available,
and next which removes the next element from the iterator and returns it. They can be called
an arbitrary amount of times. If hasNext returns false, a call of next will throw
a NoSuchElementException.
Caution
Other methods than hasNext and next can be called only once (exclusively).
More specifically, after calling a method it cannot be guaranteed that the next call will succeed.
An Iterator that can be only used once because it is a traversal pointer into a collection, and not a collection itself.
| Modifier and Type | Method and Description |
|---|---|
| public default <R> Iterator | collect(PartialFunction<? super T, ? extends R>
A function that is not necessarily defined of all elements of this traversable. partialFunction)Implements io. Collects all elements that are in the domain of the given |
| public static < Component type. T> Iterator | |
| public static < Component type. T> Iterator | |
| public default Iterator | |
| public static < value type T> Iterator | Returns: A newIteratorA Supplier of iterator values supplier)Generates an infinite iterator using a value Supplier. |
| public static < Element type T> Iterator | Returns: A new Iterator containing infinitet's.An element t)Creates an infinite iterator returning the given element. |
| public default Iterator | distinct()
Implements io. Returns a new version of this which contains no duplicates. |
| public default Iterator | distinctBy(Comparator<? super T>
A comparator comparator)Implements io. Returns a new version of this which contains no duplicates. |
| public default <U> Iterator | distinctBy(Function<? super T, ? extends U>
A key extractor keyExtractor)Implements io. Returns a new version of this which contains no duplicates. |
| public default Iterator | Returns: The empty iterator, ifn <= 0 or this is empty, otherwise a new iterator without the first n elements.A number n)Implements io. Removes up to n elements from this iterator. |
| public default Iterator | dropRight(int
The number of elements to drop. n)Implements io. Drops the last n elements of this or all elements, if this length < n. |
| public default Iterator | dropUntil(Predicate<? super T>
A condition tested subsequently for this elements. predicate)Implements io. Drops elements until the predicate holds for the current element. |
| public default Iterator | dropWhile(Predicate<? super T>
A condition tested subsequently for this elements. predicate)Implements io. Drops elements while the predicate holds for the current element. |
| public static < Component type T> Iterator | |
| public static < Component type of the Iterator T> Iterator | |
| public static < Component type of the Iterator T> Iterator | Returns: An iterator ofn sequence elements, where each element is the given element.The number of elements n, T The element element)Returns a Iterator containing |
| public default Iterator | Returns: A new IteratorA predicate predicate)Implements io. Returns an Iterator that contains elements that satisfy the given |
| public default Option | findLast(Predicate<? super T>
A predicate. predicate)Overrides default io. Returns the last element of this which satisfies the given predicate. |
| public default < Component type U> Iterator | Returns: A new IterableA mapper mapper)Implements io. FlatMaps the elements of this Iterator to Iterables, which are iterated in the order of occurrence. |
| public default <U> U | foldRight(U
A zero element to start with. zero, BiFunction<? super T, ? super U, ? extends U> A function which combines elements. f)Implements io. Folds this elements from the right, starting with |
| public static Iterator | Returns: a newIterator of int values starting from froma start int value value)Returns an infinite iterator of int values starting from |
| public static Iterator | Returns: a newIterator of int values starting from froma start int value value, int the step by which to advance on each iteration step)Returns an infinite iterator of int values starting from |
| public static Iterator | Returns: a newIterator of long values starting from froma start long value value)Returns an infinite iterator of long values starting from |
| public static Iterator | Returns: a newIterator of long values starting from froma start long value value, long the step by which to advance on each iteration step)Returns an infinite iterator of long values starting from |
| public default T | get()
Overrides default io. Gets the first value in iteration order if this |
| public default <C> Map | groupBy(Function<? super T, ? extends C>
A function which classifies elements into classes classifier)Implements io. Groups this elements by classifying the elements. |
| public default Iterator | grouped(int
a positive block size size)Implements io. Groups this |
| public default boolean | hasDefiniteSize()
Implements io. Checks if this Traversable is known to have a finite size. |
| public default T | head()
Implements io. Returns the first element of a non-empty Traversable. |
| public default Iterator | init()
Implements io. Dual of tail(), returning all elements except the last. |
| public default Option | initOption()
Overrides default io. Dual of tailOption(), returning all elements except the last as |
| public default Iterator | Returns: an interspersed version of thisAn element. element)Inserts an element between all elements of this Iterator. |
| public default boolean | |
| public default boolean | isEmpty()
Overrides default io. Checks if this Traversable is empty. |
| public default boolean | |
| public default boolean | isSequential()
Overrides default io. Checks if the elements of this Traversable appear in encounter order. |
| public default boolean | isTraversableAgain()
Implements io. Checks if this Traversable can be repeatedly traversed. |
| public static < value type T> Iterator | |
| public static < value type T> Iterator | |
| public default Iterator | iterator()
Overrides default io. An iterator by means of head() and tail(). |
| public default T | |
| public default int | length()
Implements io. Computes the number of elements of this Traversable. |
| public default < Component type U> Iterator | Returns: A new IteratorA mapper. mapper)Implements io. Maps the elements of this Iterator lazily using the given |
| public static < Component type of the T> IteratorIterator. | |
| public static < Component type. T> Iterator | |
| public static < Component type T> Iterator | Returns: A new IteratorZero or more elements elements)Creates an Iterator which traverses the given elements. |
| public static < Component type. T> Iterator | |
| public static < Component type. T> Iterator | |
| public static Iterator | Returns: A new Iterator of Boolean valuesboolean values elements)Creates an Iterator from boolean values. |
| public static Iterator | Returns: A new Iterator of Byte valuesbyte values elements)Creates an Iterator from byte values. |
| public static Iterator | Returns: A new Iterator of Character valueschar values elements)Creates an Iterator from char values. |
| public static Iterator | Returns: A new Iterator of Double valuesdouble values elements)Creates ann Iterator from double values. |
| public static Iterator | Returns: A new Iterator of Float valuesfloat values elements)Creates an Iterator from float values. |
| public static Iterator | Returns: A new Iterator of Integer valuesint values elements)Creates an Iterator from int values. |
| public static Iterator | Returns: A new Iterator of Long valueslong values elements)Creates an Iterator from long values. |
| public static Iterator | Returns: A new Iterator of Short valuesshort values elements)Creates an Iterator from short values. |
| public default Iterator | orElse(Iterable<? extends T>
An alternative other)TraversableImplements io. Returns this |
| public default Iterator | orElse(Supplier<? extends Iterable<? extends T>>
An alternative supplier)Traversable supplierImplements io. Returns this |
| public default Tuple2 | partition(Predicate<? super T>
A predicate which classifies an element if it is in the first or the second traversable. predicate)Implements io. Creates a partition of this |
| public default Iterator | peek(Consumer<? super T>
The action that will be performed on the element(s). action)Implements io. Performs the given |
| public static Iterator | Returns: a range of characters as specified or the empty range iffrom >= toExclusivethe first character from, char the successor of the last character toExclusive)Creates an Iterator of characters starting from |
| public static Iterator | Returns: a range of int values as specified or the empty range iffrom >= toExclusivethe first number from, int the last number + 1 toExclusive)Creates an Iterator of int numbers starting from |
| public static Iterator | Returns: a range of long values as specified or the empty range iffrom >= toExclusivethe first number from, long the last number + 1 toExclusive)Creates an Iterator of long numbers starting from |
| public static Iterator | Returns: a range of characters as specified or the empty range ifsignum(step) == signum(from - toExclusive).the first character from, char the successor of the last character if step > 0, the predecessor of the last character if step < 0 toExclusive, int the step step)Creates an Iterator of characters starting from |
| public static Iterator | |
| public static Iterator | |
| public static Iterator | Returns: a range of long values as specified or the empty range if(from == toExclusive) || (step * (from - toExclusive) > 0).the first number from, int the last number + 1 if step > 0, the last number - 1 if step < 0 toExclusive, int the step step)Creates an Iterator of int numbers starting from |
| public static Iterator | Returns: a range of long values as specified or the empty range if(from == toExclusive) || (step * (from - toExclusive) > 0).the first number from, long the last number + 1 if step > 0, the last number - 1 if step < 0 toExclusive, long the step step)Creates an Iterator of long numbers starting from |
| public static Iterator | Returns: a range of characters as specified or the empty range iffrom > toInclusivethe first character from, char the last character toInclusive)Creates an Iterator of characters starting from |
| public static Iterator | Returns: a range of int values as specified or the empty range iffrom > toInclusivethe first number from, int the last number toInclusive)Creates an Iterator of int numbers starting from |
| public static Iterator | Returns: a range of long values as specified or the empty range iffrom > toInclusivethe first number from, long the last number toInclusive)Creates an Iterator of long numbers starting from |
| public static Iterator | Returns: a range of characters as specified or the empty range ifsignum(step) == signum(from - toInclusive).the first character from, char the last character toInclusive, int the step step)Creates an Iterator of characters starting from |
| public static Iterator | |
| public static Iterator | Returns: a range of int values as specified or the empty range ifsignum(step) == signum(from - toInclusive).the first number from, int the last number toInclusive, int the step step)Creates an Iterator of int numbers starting from |
| public static Iterator | Returns: a range of int values as specified or the empty range ifsignum(step) == signum(from - toInclusive).the first number from, long the last number toInclusive, long the step step)Creates an Iterator of long numbers starting from |
| public default T | reduceLeft(BiFunction<? super T, ? super T, ? extends T>
A BiFunction of type T op)Overrides default io. Accumulates the elements of this Traversable by successively calling the given operation |
| public default T | reduceRight(BiFunction<? super T, ? super T, ? extends T>
An operation of type T op)Overrides default io. Accumulates the elements of this Traversable by successively calling the given operation |
| public default Iterator | reject(Predicate<? super T>
A predicate predicate)Overrides default io. Returns a new traversable consisting of all elements which do not satisfy the given predicate. |
| public default Iterator | replace(T
An element to be substituted. currentElement, T A replacement for currentElement. newElement)Implements io. Replaces the first occurrence (if exists) of the given currentElement with newElement. |
| public default Iterator | replaceAll(T
An element to be substituted. currentElement, T A replacement for currentElement. newElement)Implements io. Replaces all occurrences of the given currentElement with newElement. |
| public default Iterator | retainAll(Iterable<? extends T>
Elements to be kept. elements)Implements io. Keeps all occurrences of the given elements from this. |
| public default Traversable | scan(T
neutral element for the operator op zero, BiFunction<? super T, ? super T, ? extends T> the associative operator for the scan operation)Implements io. Computes a prefix scan of the elements of the collection. |
| public default <U> Iterator | scanLeft(U
the initial value zero, BiFunction<? super U, ? super T, ? extends U> the binary operator applied to the intermediate result and the element operation)Implements io. Produces a collection containing cumulative results of applying the operator going left to right. |
| public default <U> Iterator | scanRight(U
the initial value zero, BiFunction<? super T, ? super U, ? extends U> the binary operator applied to the intermediate result and the element operation)Implements io. Produces a collection containing cumulative results of applying the operator going right to left. |
| public default Iterator | slideBy(Function<? super T, ?>
A function which classifies elements into classes classifier)Implements io. Slides a non-overlapping window of a variable size over this |
| public default Iterator | sliding(int
a positive window size size)Implements io. Slides a window of a specific |
| public default Iterator | sliding(int
a positive window size size, int a positive step size step)Implements io. Slides a window of a specific |
| public default Tuple2 | span(Predicate<? super T>
A predicate. predicate)Implements io. Returns a tuple where the first element is the longest prefix of elements that satisfy the given
|
| public default String | stringPrefix()
Implements io. Returns the name of this Value type, which is used by toString(). |
| public static < Component type of the Iterator T> Iterator | Returns: An Iterator on a sequence of elementsf(0),f(1), ..., f(n - 1)The number of elements n, Function<? super Integer, ? extends T> The Function computing element values f)Returns an Iterator on a sequence of |
| public default Iterator | tail()
Implements io. Drops the first element of a non-empty Traversable. |
| public default Option | tailOption()
Implements io. Drops the first element of a non-empty Traversable and returns an |
| public default Iterator | Returns: The empty iterator, ifn <= 0 or this is empty, otherwise a new iterator without the first n elements.A number n)Implements io. Take the first n elements from this iterator. |
| public default Iterator | takeRight(int
The number of elements to take. n)Implements io. Takes the last n elements of this or all elements, if this length < n. |
| public default Iterator | takeUntil(Predicate<? super T>
A condition tested subsequently for this elements. predicate)Implements io. Takes elements until the predicate holds for the current element. |
| public default Iterator | takeWhile(Predicate<? super T>
A condition tested subsequently for the contained elements. predicate)Implements io. Takes elements while the predicate holds for the current element. |
| public default < Type of transformation result U> U | |
| public static < type of seeds and unfolded values T> Iterator | |
| public static < type of seeds T, type of unfolded values U> Iterator | Returns: a list with the values built up by the iterationthe start value for the iteration seed, Function<? super T, Option<Tuple2<? extends T, ? extends U>>> the function to get the next step of the iteration f)Creates an iterator from a seed value and a function. |
| public static < type of seeds T, type of unfolded values U> Iterator | Returns: a list with the values built up by the iterationthe start value for the iteration seed, Function<? super T, Option<Tuple2<? extends U, ? extends T>>> the function to get the next step of the iteration f)Creates an iterator from a seed value and a function. |
| public default <T1, T2> Tuple2 | unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>>
a function which converts elements of this to pairs unzipper)Implements io. Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct sets. |
| public default <T1, T2, T3> Tuple3 | unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>>
a function which converts elements of this to pairs unzipper)Implements io. Unzips this elements by mapping this elements to triples which are subsequently split into three distinct sets. |
| public default <U> Iterator | zip(Iterable<? extends U>
The Iterable providing the second half of each result pair. that)Implements io. Returns a traversable formed from this traversable and another Iterable collection by combining corresponding elements in pairs. |
| public default <U> Iterator | zipAll(Iterable<? extends U>
The Iterable providing the second half of each result pair. that, T The element to be used to fill up the result if this traversable is shorter than that. thisElem, U The element to be used to fill up the result if that is shorter than this traversable. thatElem)Implements io. Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in pairs. |
| public default <U, R> Iterator | zipWith(Iterable<? extends U>
The Iterable providing the second parameter of the mapper. that, BiFunction<? super T, ? super U, ? extends R> a mapper. mapper)Implements io. Returns a traversable formed from this traversable and another Iterable collection by mapping elements. |
| public default Iterator | zipWithIndex()
Implements io. Zips this traversable with its indices. |
| public default <U> Iterator | zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U>
a mapper. mapper)Implements io. Zips this traversable with its indices by applying mapper provided. |