# ObjectList

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/ObjectList.kt+class:androidx.collection.ObjectList) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

*** ** * ** ***


```
public sealed class ObjectList<E extends Object>
```

<br />

Known direct subclasses [MutableObjectList](https://developer.android.com/reference/androidx/collection/MutableObjectList)

|---|---|
| `https://developer.android.com/reference/androidx/collection/MutableObjectList` | `https://developer.android.com/reference/androidx/collection/MutableObjectList` is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html`-like collection for reference types. |

*** ** * ** ***

`https://developer.android.com/reference/androidx/collection/ObjectList` is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html`-like collection for reference types. It is optimized for fast access, avoiding virtual and interface method access. Methods avoid allocation whenever possible. For example `https://developer.android.com/reference/androidx/collection/ObjectList#forEach(kotlin.Function1)` does not need allocate an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterator/index.html`.

This implementation is not thread-safe: if multiple threads access this container concurrently, and one or more threads modify the structure of the list (insertion or removal for instance), the calling code must provide the appropriate synchronization. It is also not safe to mutate during reentrancy -- in the middle of a `https://developer.android.com/reference/androidx/collection/ObjectList#forEach(kotlin.Function1)`, for example. However, concurrent reads are safe.

**Note** `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` access is available through `https://developer.android.com/reference/androidx/collection/ObjectList#asList()` when developers need access to the common API.

It is best to use this for all internal implementations where a list of reference types is needed. Use `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` in public API to take advantage of the commonly-used interface. It is common to use `https://developer.android.com/reference/androidx/collection/ObjectList` internally and use `https://developer.android.com/reference/androidx/collection/ObjectList#asList()` to get a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` interface for interacting with public APIs.

LongList

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/collection/MutableObjectList` |   |
| `https://developer.android.com/reference/androidx/collection/FloatList` |   |
| `https://developer.android.com/reference/androidx/collection/IntList` |   |

## Summary

| ### Protected constructors |
|---|
| `<E extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ObjectList#ObjectList(kotlin.Int)(int initialCapacity)` |

| ### Public methods |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#any()()` Returns `true` if there's at least one element in the collection. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#any(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns `true` if any of the elements give a `true` return value for `https://developer.android.com/reference/androidx/collection/ObjectList#any(kotlin.Function1)`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull E>` | `https://developer.android.com/reference/androidx/collection/ObjectList#asList()()` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` view into the `https://developer.android.com/reference/androidx/collection/ObjectList`. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Int,kotlin.Int,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int fromIndex, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int toIndex, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html> comparison )` Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for an element for which the given `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Int,kotlin.Int,kotlin.Function1)` function returns zero using binary search algorithm. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Any,kotlin.Comparator,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull E element, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-comparator/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> comparator, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int fromIndex, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int toIndex )` Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for the provided `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Any,kotlin.Comparator,kotlin.Int,kotlin.Int)` using the specified `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Any,kotlin.Comparator,kotlin.Int,kotlin.Int)` across elements. |
| `final int` | `<K extends https://developer.android.com/reference/java/lang/Comparable.html<@https://developer.android.com/reference/androidx/annotation/NonNull K>> https://developer.android.com/reference/androidx/collection/ObjectList#binarySearchBy(kotlin.Comparable,kotlin.Int,kotlin.Int,kotlin.Function1)( K key, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int fromIndex, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int toIndex, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, K> selector )` Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for an element having a key returned by `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearchBy(kotlin.Comparable,kotlin.Int,kotlin.Int,kotlin.Function1)` equal to the specified `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearchBy(kotlin.Comparable,kotlin.Int,kotlin.Int,kotlin.Function1)` using binary search algorithm. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#contains(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains `https://developer.android.com/reference/androidx/collection/ObjectList#contains(kotlin.Any)` or `false` otherwise. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements)` Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.Array)` or `false` if one or more are missing. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.collections.Iterable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.collections.Iterable)` or `false` if one or more are missing. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.collections.List)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.collections.List)` or `false` if one or more are missing. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(androidx.collection.ObjectList)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(androidx.collection.ObjectList)` or `false` if one or more are missing. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#count()()` Returns the number of elements in this list. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#count(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Counts the number of elements matching `https://developer.android.com/reference/androidx/collection/ObjectList#count(kotlin.Function1)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#elementAt(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int index)` Returns the element at the given `https://developer.android.com/reference/androidx/collection/ObjectList#elementAt(kotlin.Int)` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` if the `https://developer.android.com/reference/androidx/collection/ObjectList#elementAt(kotlin.Int)` is out of bounds of this collection. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int index, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull E> defaultValue )` Returns the element at the given `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` or `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` if `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` is out of bounds of the collection. |
| `boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` Returns `true` if `https://developer.android.com/reference/androidx/collection/ObjectList#equals(kotlin.Any)` is a `https://developer.android.com/reference/androidx/collection/ObjectList` and the contents of this and `https://developer.android.com/reference/androidx/collection/ObjectList#equals(kotlin.Any)` are the same. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#first()()` Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or throws a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#first(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#first(kotlin.Function1)` returns `true` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if nothing matches. |
| `final E` | `https://developer.android.com/reference/androidx/collection/ObjectList#firstOrNull()()` Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `null` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`. |
| `final E` | `https://developer.android.com/reference/androidx/collection/ObjectList#firstOrNull(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate )` Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#firstOrNull(kotlin.Function1)` returns `true` or `null` if nothing matches. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ObjectList#fold(kotlin.Any,kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull R initial, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull acc, @https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull R> operation )` Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#fold(kotlin.Any,kotlin.Function2)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#fold(kotlin.Any,kotlin.Function2)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in order. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ObjectList#foldIndexed(kotlin.Any,kotlin.Function3)( @https://developer.android.com/reference/androidx/annotation/NonNull R initial, @https://developer.android.com/reference/androidx/annotation/NonNull Function3<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull acc, @https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull R> operation )` Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#foldIndexed(kotlin.Any,kotlin.Function3)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#foldIndexed(kotlin.Any,kotlin.Function3)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in order. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ObjectList#foldRight(kotlin.Any,kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull R initial, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull acc, @https://developer.android.com/reference/androidx/annotation/NonNull R> operation )` Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#foldRight(kotlin.Any,kotlin.Function2)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#foldRight(kotlin.Any,kotlin.Function2)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in reverse order. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ObjectList#foldRightIndexed(kotlin.Any,kotlin.Function3)( @https://developer.android.com/reference/androidx/annotation/NonNull R initial, @https://developer.android.com/reference/androidx/annotation/NonNull Function3<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull acc, @https://developer.android.com/reference/androidx/annotation/NonNull R> operation )` Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#foldRightIndexed(kotlin.Any,kotlin.Function3)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#foldRightIndexed(kotlin.Any,kotlin.Function3)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in reverse order. |
| `final void` | `https://developer.android.com/reference/androidx/collection/ObjectList#forEach(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEach(kotlin.Function1)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList`, in order. |
| `final void` | `https://developer.android.com/reference/androidx/collection/ObjectList#forEachIndexed(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block )` Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEachIndexed(kotlin.Function2)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` along with its index, in order. |
| `final void` | `https://developer.android.com/reference/androidx/collection/ObjectList#forEachReversed(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEachReversed(kotlin.Function1)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in reverse order. |
| `final void` | `https://developer.android.com/reference/androidx/collection/ObjectList#forEachReversedIndexed(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block )` Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEachReversedIndexed(kotlin.Function2)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` along with its index, in reverse order. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#get(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int index)` Returns the element at the given `https://developer.android.com/reference/androidx/collection/ObjectList#get(kotlin.Int)` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` if the `https://developer.android.com/reference/androidx/collection/ObjectList#get(kotlin.Int)` is out of bounds of this collection. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html` | `https://developer.android.com/reference/androidx/collection/ObjectList#getIndices()()` Returns an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html` of the valid indices for this `https://developer.android.com/reference/androidx/collection/ObjectList`. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = -1) int` | `https://developer.android.com/reference/androidx/collection/ObjectList#getLastIndex()()` Returns the last valid index in the `https://developer.android.com/reference/androidx/collection/ObjectList`. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/ObjectList#getSize()()` The number of elements in the `https://developer.android.com/reference/androidx/collection/ObjectList`. |
| `int` | `https://developer.android.com/reference/androidx/collection/ObjectList#hashCode()()` Returns a hash code based on the contents of the `https://developer.android.com/reference/androidx/collection/ObjectList`. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#indexOf(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Returns the index of `https://developer.android.com/reference/androidx/collection/ObjectList#indexOf(kotlin.Any)` in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `-1` if `https://developer.android.com/reference/androidx/collection/ObjectList#indexOf(kotlin.Any)` is not there. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfFirst(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate )` Returns the index if the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfFirst(kotlin.Function1)` returns `true` or -1 if there was no element for which predicate returned `true`. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfLast(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate )` Returns the index if the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfLast(kotlin.Function1)` returns `true` or -1 if there was no element for which predicate returned `true`. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()()` Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` has no elements in it or `false` otherwise. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#isNotEmpty()()` Returns `true` if there are elements in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `false` if it is empty. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html separator, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html prefix, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html postfix, int limit, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html truncated, Function1<@https://developer.android.com/reference/androidx/annotation/NonNull E, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html> transform )` Creates a String from the elements separated by `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` and using `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` before and `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` after, if supplied. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#last()()` Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or throws a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ObjectList#last(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#last(kotlin.Function1)` returns `true` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if nothing matches. |
| `final int` | `https://developer.android.com/reference/androidx/collection/ObjectList#lastIndexOf(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Returns the index of the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` that is the same as `https://developer.android.com/reference/androidx/collection/ObjectList#lastIndexOf(kotlin.Any)` or `-1` if no elements match. |
| `final E` | `https://developer.android.com/reference/androidx/collection/ObjectList#lastOrNull()()` Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `null` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`. |
| `final E` | `https://developer.android.com/reference/androidx/collection/ObjectList#lastOrNull(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#lastOrNull(kotlin.Function1)` returns `true` or `null` if nothing matches. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#none()()` Returns `true` if the collection has no elements in it. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ObjectList#reversedAny(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate )` Returns `true` if any of the elements give a `true` return value for `https://developer.android.com/reference/androidx/collection/ObjectList#reversedAny(kotlin.Function1)` while iterating in the reverse order. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/collection/ObjectList#toString()()` Returns a String representation of the list, surrounded by "\[\]" and each element separated by ", ". |

| ### Extension functions |
|---|---|
| `final int` | `<E extends https://developer.android.com/reference/java/lang/Comparable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E>> https://developer.android.com/reference/androidx/collection/ObjectListKt.https://developer.android.com/reference/androidx/collection/ObjectList#(androidx.collection.ObjectList).binarySearch(kotlin.Comparable,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull E element, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int fromIndex, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int toIndex )` Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for the provided `https://developer.android.com/reference/androidx/collection/package-summary#(androidx.collection.ObjectList).binarySearch(kotlin.Comparable,kotlin.Int,kotlin.Int)` using binary search algorithm. |

## Protected constructors

### ObjectList

```
protected <E extends Object> ObjectList(int initialCapacity)
```

## Public methods

### any

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean any()
```

Returns `true` if there's at least one element in the collection.

### any

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean any(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns `true` if any of the elements give a `true` return value for `https://developer.android.com/reference/androidx/collection/ObjectList#any(kotlin.Function1)`.

### asList

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public abstract @NonNull List<@NonNull E> asList()
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` view into the `https://developer.android.com/reference/androidx/collection/ObjectList`. All access to the collection will be less efficient and abides by the allocation requirements of the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html`. For example, `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/index.html` will allocate an iterator. All access will go through the more expensive interface calls. Critical performance areas should use the `https://developer.android.com/reference/androidx/collection/ObjectList` API rather than `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` API, when possible.

### binarySearch

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/collection#1.7.0)

```
public final int binarySearch(
    @IntRange(from = 0) int fromIndex,
    @IntRange(from = 0) int toIndex,
    @NonNull Function1<@NonNull element, @NonNull Integer> comparison
)
```

Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for an element for which the given `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Int,kotlin.Int,kotlin.Function1)` function returns zero using binary search algorithm.

### binarySearch

```
public final int binarySearch(
    @NonNull E element,
    @NonNull Comparator<@NonNull E> comparator,
    @IntRange(from = 0) int fromIndex,
    @IntRange(from = 0) int toIndex
)
```

Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for the provided `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Any,kotlin.Comparator,kotlin.Int,kotlin.Int)` using the specified `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Any,kotlin.Comparator,kotlin.Int,kotlin.Int)` across elements. The list is expected to be sorted in order specified by `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearch(kotlin.Any,kotlin.Comparator,kotlin.Int,kotlin.Int)`.

### binarySearchBy

```
public final int <K extends Comparable<@NonNull K>> binarySearchBy(
    K key,
    @IntRange(from = 0) int fromIndex,
    @IntRange(from = 0) int toIndex,
    @NonNull Function1<@NonNull element, K> selector
)
```

Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for an element having a key returned by `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearchBy(kotlin.Comparable,kotlin.Int,kotlin.Int,kotlin.Function1)` equal to the specified `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearchBy(kotlin.Comparable,kotlin.Int,kotlin.Int,kotlin.Function1)` using binary search algorithm. The list is expected to be sorted in ascending order according to the natural ordering of keys produced by `https://developer.android.com/reference/androidx/collection/ObjectList#binarySearchBy(kotlin.Comparable,kotlin.Int,kotlin.Int,kotlin.Function1)`.

### contains

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean contains(@NonNull E element)
```

Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains `https://developer.android.com/reference/androidx/collection/ObjectList#contains(kotlin.Any)` or `false` otherwise.

### containsAll

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean containsAll(@NonNull E[] elements)
```

Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.Array)` or `false` if one or more are missing.

### containsAll

```
public final boolean containsAll(@NonNull Iterable<@NonNull E> elements)
```

Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.collections.Iterable)` or `false` if one or more are missing.

### containsAll

```
public final boolean containsAll(@NonNull List<@NonNull E> elements)
```

Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(kotlin.collections.List)` or `false` if one or more are missing.

### containsAll

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean containsAll(@NonNull ObjectList<@NonNull E> elements)
```

Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` contains all elements in `https://developer.android.com/reference/androidx/collection/ObjectList#containsAll(androidx.collection.ObjectList)` or `false` if one or more are missing.

### count

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final int count()
```

Returns the number of elements in this list.

### count

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final int count(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Counts the number of elements matching `https://developer.android.com/reference/androidx/collection/ObjectList#count(kotlin.Function1)`.

| Returns |
|---|---|
| `int` | The number of elements in this list for which `https://developer.android.com/reference/androidx/collection/ObjectList#count(kotlin.Function1)` returns true. |

### elementAt

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E elementAt(@IntRange(from = 0) int index)
```

Returns the element at the given `https://developer.android.com/reference/androidx/collection/ObjectList#elementAt(kotlin.Int)` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` if the `https://developer.android.com/reference/androidx/collection/ObjectList#elementAt(kotlin.Int)` is out of bounds of this collection.

### elementAtOrElse

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E elementAtOrElse(
    @IntRange(from = 0) int index,
    @NonNull Function1<@NonNull Integer, @NonNull E> defaultValue
)
```

Returns the element at the given `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` or `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` if `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` is out of bounds of the collection.

| Parameters |
|---|---|
| `index: int` | The index of the element whose value should be returned |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull E> defaultValue` | A lambda to call with `https://developer.android.com/reference/androidx/collection/ObjectList#elementAtOrElse(kotlin.Int,kotlin.Function1)` as a parameter to return a value at an index not in the list. |

### equals

```
public boolean equals(Object other)
```

Returns `true` if `https://developer.android.com/reference/androidx/collection/ObjectList#equals(kotlin.Any)` is a `https://developer.android.com/reference/androidx/collection/ObjectList` and the contents of this and `https://developer.android.com/reference/androidx/collection/ObjectList#equals(kotlin.Any)` are the same.

### first

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E first()
```

Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or throws a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`.

### first

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E first(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#first(kotlin.Function1)` returns `true` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if nothing matches.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfFirst(kotlin.Function1)` |   |
| `https://developer.android.com/reference/androidx/collection/ObjectList#firstOrNull()` |   |

### firstOrNull

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final E firstOrNull()
```

Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `null` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`.

### firstOrNull

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final E firstOrNull(
    @NonNull Function1<@NonNull element, @NonNull Boolean> predicate
)
```

Returns the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#firstOrNull(kotlin.Function1)` returns `true` or `null` if nothing matches.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfFirst(kotlin.Function1)` |   |

### fold

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull R <R extends Object> fold(
    @NonNull R initial,
    @NonNull Function2<@NonNull acc, @NonNull element, @NonNull R> operation
)
```

Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#fold(kotlin.Any,kotlin.Function2)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#fold(kotlin.Any,kotlin.Function2)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull R initial` | The value of `acc` for the first call to `https://developer.android.com/reference/androidx/collection/ObjectList#fold(kotlin.Any,kotlin.Function2)` or return value if there are no elements in this list. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull acc, @https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull R> operation` | function that takes current accumulator value and an element, and calculates the next accumulator value. |

### foldIndexed

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull R <R extends Object> foldIndexed(
    @NonNull R initial,
    @NonNull Function3<@NonNull Integer, @NonNull acc, @NonNull element, @NonNull R> operation
)
```

Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#foldIndexed(kotlin.Any,kotlin.Function3)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#foldIndexed(kotlin.Any,kotlin.Function3)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in order.

### foldRight

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull R <R extends Object> foldRight(
    @NonNull R initial,
    @NonNull Function2<@NonNull element, @NonNull acc, @NonNull R> operation
)
```

Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#foldRight(kotlin.Any,kotlin.Function2)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#foldRight(kotlin.Any,kotlin.Function2)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in reverse order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull R initial` | The value of `acc` for the first call to `https://developer.android.com/reference/androidx/collection/ObjectList#foldRight(kotlin.Any,kotlin.Function2)` or return value if there are no elements in this list. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull acc, @https://developer.android.com/reference/androidx/annotation/NonNull R> operation` | function that takes an element and the current accumulator value, and calculates the next accumulator value. |

### foldRightIndexed

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull R <R extends Object> foldRightIndexed(
    @NonNull R initial,
    @NonNull Function3<@NonNull Integer, @NonNull element, @NonNull acc, @NonNull R> operation
)
```

Accumulates values, starting with `https://developer.android.com/reference/androidx/collection/ObjectList#foldRightIndexed(kotlin.Any,kotlin.Function3)`, and applying `https://developer.android.com/reference/androidx/collection/ObjectList#foldRightIndexed(kotlin.Any,kotlin.Function3)` to each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in reverse order.

### forEach

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final void forEach(@NonNull Function1<@NonNull element, Unit> block)
```

Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEach(kotlin.Function1)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList`, in order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | will be executed for every element in the list, accepting an element from the list |

### forEachIndexed

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final void forEachIndexed(
    @NonNull Function2<@NonNull Integer, @NonNull element, Unit> block
)
```

Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEachIndexed(kotlin.Function2)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` along with its index, in order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | will be executed for every element in the list, accepting the index and the element at that index. |

### forEachReversed

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final void forEachReversed(@NonNull Function1<@NonNull element, Unit> block)
```

Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEachReversed(kotlin.Function1)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` in reverse order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | will be executed for every element in the list, accepting an element from the list |

### forEachReversedIndexed

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final void forEachReversedIndexed(
    @NonNull Function2<@NonNull Integer, @NonNull element, Unit> block
)
```

Calls `https://developer.android.com/reference/androidx/collection/ObjectList#forEachReversedIndexed(kotlin.Function2)` for each element in the `https://developer.android.com/reference/androidx/collection/ObjectList` along with its index, in reverse order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | will be executed for every element in the list, accepting the index and the element at that index. |

### get

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E get(@IntRange(from = 0) int index)
```

Returns the element at the given `https://developer.android.com/reference/androidx/collection/ObjectList#get(kotlin.Int)` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` if the `https://developer.android.com/reference/androidx/collection/ObjectList#get(kotlin.Int)` is out of bounds of this collection.

### getIndices

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull IntRange getIndices()
```

Returns an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html` of the valid indices for this `https://developer.android.com/reference/androidx/collection/ObjectList`.

### getLastIndex

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @IntRange(from = -1) int getLastIndex()
```

Returns the last valid index in the `https://developer.android.com/reference/androidx/collection/ObjectList`. This can be `-1` when the list is empty.

### getSize

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @IntRange(from = 0) int getSize()
```

The number of elements in the `https://developer.android.com/reference/androidx/collection/ObjectList`.

### hashCode

```
public int hashCode()
```

Returns a hash code based on the contents of the `https://developer.android.com/reference/androidx/collection/ObjectList`.

### indexOf

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final int indexOf(@NonNull E element)
```

Returns the index of `https://developer.android.com/reference/androidx/collection/ObjectList#indexOf(kotlin.Any)` in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `-1` if `https://developer.android.com/reference/androidx/collection/ObjectList#indexOf(kotlin.Any)` is not there.

### indexOfFirst

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final int indexOfFirst(
    @NonNull Function1<@NonNull element, @NonNull Boolean> predicate
)
```

Returns the index if the first element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfFirst(kotlin.Function1)` returns `true` or -1 if there was no element for which predicate returned `true`.

### indexOfLast

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final int indexOfLast(
    @NonNull Function1<@NonNull element, @NonNull Boolean> predicate
)
```

Returns the index if the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfLast(kotlin.Function1)` returns `true` or -1 if there was no element for which predicate returned `true`.

### isEmpty

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean isEmpty()
```

Returns `true` if the `https://developer.android.com/reference/androidx/collection/ObjectList` has no elements in it or `false` otherwise.

### isNotEmpty

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean isNotEmpty()
```

Returns `true` if there are elements in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `false` if it is empty.

### joinToString

```
public final @NonNull String joinToString(
    @NonNull CharSequence separator,
    @NonNull CharSequence prefix,
    @NonNull CharSequence postfix,
    int limit,
    @NonNull CharSequence truncated,
    Function1<@NonNull E, @NonNull CharSequence> transform
)
```

Creates a String from the elements separated by `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` and using `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` before and `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` after, if supplied.

When a non-negative value of `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` is provided, a maximum of `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` items are used to generate the string. If the collection holds more than `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` items, the string is terminated with `https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)`.

`https://developer.android.com/reference/androidx/collection/ObjectList#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` may be supplied to convert each element to a custom String.

### last

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E last()
```

Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or throws a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`.

### last

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E last(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#last(kotlin.Function1)` returns `true` or throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` if nothing matches.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfLast(kotlin.Function1)` |   |
| `https://developer.android.com/reference/androidx/collection/ObjectList#lastOrNull()` |   |

### lastIndexOf

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final int lastIndexOf(@NonNull E element)
```

Returns the index of the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` that is the same as `https://developer.android.com/reference/androidx/collection/ObjectList#lastIndexOf(kotlin.Any)` or `-1` if no elements match.

### lastOrNull

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final E lastOrNull()
```

Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` or `null` if it `https://developer.android.com/reference/androidx/collection/ObjectList#isEmpty()`.

### lastOrNull

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final E lastOrNull(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns the last element in the `https://developer.android.com/reference/androidx/collection/ObjectList` for which `https://developer.android.com/reference/androidx/collection/ObjectList#lastOrNull(kotlin.Function1)` returns `true` or `null` if nothing matches.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/collection/ObjectList#indexOfLast(kotlin.Function1)` |   |

### none

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean none()
```

Returns `true` if the collection has no elements in it.

### reversedAny

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean reversedAny(
    @NonNull Function1<@NonNull element, @NonNull Boolean> predicate
)
```

Returns `true` if any of the elements give a `true` return value for `https://developer.android.com/reference/androidx/collection/ObjectList#reversedAny(kotlin.Function1)` while iterating in the reverse order.

### toString

```
public @NonNull String toString()
```

Returns a String representation of the list, surrounded by "\[\]" and each element separated by ", ".

## Extension functions

### ObjectListKt.binarySearch

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/ObjectList.kt+function:binarySearch)

```
public final int <E extends Comparable<@NonNull E>> ObjectListKt.binarySearch(
    @NonNull ObjectList<@NonNull E> receiver,
    @NonNull E element,
    @IntRange(from = 0) int fromIndex,
    @IntRange(from = 0) int toIndex
)
```

Searches this `https://developer.android.com/reference/androidx/collection/ObjectList` or its range for the provided `https://developer.android.com/reference/androidx/collection/package-summary#(androidx.collection.ObjectList).binarySearch(kotlin.Comparable,kotlin.Int,kotlin.Int)` using binary search algorithm. The list is expected to be sorted in ascending order according to the natural ordering of elements.