indexOf

inline fun <T> Iterable<T>.indexOf(noinline predicate: (T) -> Boolean): Int(source)

Returns the index in this of the first element that satisfies the provided predicate, or -1 if the Iterable has no such elements.

More formally, returns the lowest index i such that predicate.apply(Iterables.get(iterable, i)) returns true, or -1 if there is no such index.

See also


inline fun <T> Iterator<T>.indexOf(noinline predicate: (T) -> Boolean): Int(source)

Returns the index in this of the first element that satisfies the provided predicate, or -1 if the Iterator has no such elements.

More formally, returns the lowest index i such that predicate.apply(Iterators.get(iterator, i)) returns true, or -1 if there is no such index.

If -1 is returned, the iterator will be left exhausted: its hasNext method will return false. Otherwise, the iterator will be set to the element which satisfies the predicate.

See also