lastIndexThat

inline fun <T> Iterable<T>.lastIndexThat(predicate: (index: Int, T) -> Boolean): Int(source)

Returns the zero-based index of the last element in this iterable for which predicate returns true.

The predicate receives the index and each element in iteration order.

Receiver

This iterable to search in iteration order.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.

Type Parameters

T

The element type of this iterable.


inline fun <T> List<T>.lastIndexThat(predicate: (index: Int, T) -> Boolean): Int(source)

Returns the zero-based index of the last element in this list for which predicate returns true.

Unlike the Iterable overload, this implementation walks the list from end to start.

Receiver

This list to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.

Type Parameters

T

The element type of this list.


inline fun <T> Array<T>.lastIndexThat(predicate: (index: Int, T) -> Boolean): Int(source)

Returns the zero-based index of the last element in this object array for which predicate returns true.

The object array is scanned from end to start; the predicate receives the index and each element.

Receiver

This object array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.

Type Parameters

T

The element type of this object array.


inline fun ByteArray.lastIndexThat(predicate: (index: Int, Byte) -> Boolean): Int(source)

Returns the zero-based index of the last element in this byte array for which predicate returns true.

The byte array is scanned from end to start; the predicate receives the index and each element.

Receiver

This byte array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun ShortArray.lastIndexThat(predicate: (index: Int, Short) -> Boolean): Int(source)

Returns the zero-based index of the last element in this short array for which predicate returns true.

The short array is scanned from end to start; the predicate receives the index and each element.

Receiver

This short array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun IntArray.lastIndexThat(predicate: (index: Int, Int) -> Boolean): Int(source)

Returns the zero-based index of the last element in this int array for which predicate returns true.

The int array is scanned from end to start; the predicate receives the index and each element.

Receiver

This int array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun LongArray.lastIndexThat(predicate: (index: Int, Long) -> Boolean): Int(source)

Returns the zero-based index of the last element in this long array for which predicate returns true.

The long array is scanned from end to start; the predicate receives the index and each element.

Receiver

This long array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun FloatArray.lastIndexThat(predicate: (index: Int, Float) -> Boolean): Int(source)

Returns the zero-based index of the last element in this float array for which predicate returns true.

The float array is scanned from end to start; the predicate receives the index and each element.

Receiver

This float array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun DoubleArray.lastIndexThat(predicate: (index: Int, Double) -> Boolean): Int(source)

Returns the zero-based index of the last element in this double array for which predicate returns true.

The double array is scanned from end to start; the predicate receives the index and each element.

Receiver

This double array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun BooleanArray.lastIndexThat(predicate: (index: Int, Boolean) -> Boolean): Int(source)

Returns the zero-based index of the last element in this boolean array for which predicate returns true.

The boolean array is scanned from end to start; the predicate receives the index and each element.

Receiver

This boolean array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.


inline fun CharArray.lastIndexThat(predicate: (index: Int, Char) -> Boolean): Int(source)

Returns the zero-based index of the last element in this char array for which predicate returns true.

The char array is scanned from end to start; the predicate receives the index and each element.

Receiver

This char array to search from end to start.

Return

The index of the last matching element, or -1 if no element satisfies predicate.

Parameters

predicate

Called with the index and each element; should return true for the index to return.