Kactoos

kactoos-jvm / nnl.rocks.kactoos.iterator / Filtered

Filtered

class Filtered<out X : Any> : Iterator<X>

Filtered iterator.

You can use it in order to create a declarative/lazy version of a filtered collection/iterable. For example, this code will create a list of two strings “red” and “fox”:

val filtered = Filtered(
    { input -> input.length < 4 },
    IteratorOf("red", "lazy", "fox")
)

There is no thread-safety guarantee.

Parameters

X - Type of item

Since 0.1

Constructors

Name Summary
<init> Filtered(predicate: KFunc<X, Boolean>, iterator: Iterator<X>)
Filtered(predicate: Func<X, Boolean>, iterator: Iterator<X>)

Functions

Name Summary
hasNext fun hasNext(): Boolean
next fun next(): X