Kactoos

kactoos-jvm / nnl.rocks.kactoos.scalar / AndWithIndex

AndWithIndex

class AndWithIndex : Scalar<Boolean>

Logical conjunction, with index.

This class can be effectively used to iterate through a collection, just like java.util.stream.Stream.forEach works, but with an index provided for each item:

new And(
  new IterableOf("Mary", "John", "William", "Napkin"),
  new BiFuncOf<>(
    (text, index) -> System.out.printf("Name #%d: %s\n", index, text),
    true
  )
).value();

There is no thread-safety guarantee.

Parameters

iterable - The iterable

Since 0.4

Constructors

Name Summary
<init> AndWithIndex(vararg src: Func<Int, Boolean>)AndWithIndex(iterable: Iterable<Func<Int, Boolean>>)
Logical conjunction, with index.

Functions

Name Summary
invoke fun invoke(): Boolean
Get value of this Scalar

Companion Object Functions

Name Summary
invoke operator fun <X : Any> invoke(proc: Proc<X>, vararg src: X): AndWithIndex
operator fun <X : Any> invoke(func: BiFunc<X, Int, Boolean>, vararg src: X): AndWithIndex
operator fun <X : Any> invoke(proc: BiProc<X, Int>, src: Iterable<X>): AndWithIndex
operator fun <X : Any> invoke(func: BiFunc<X, Int, Boolean>, src: Iterable<X>): AndWithIndex