# LongArray

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/LongArray.java+class:androidx.media3.common.util.LongArray)

*** ** * ** ***

<br />

```
@UnstableApi
class LongArray
```

<br />

*** ** * ** ***

An append-only, auto-growing `long[]`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#LongArray()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#LongArray(int)(initialCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#add(long)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Appends a value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#addAll(long[])(values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!)` Appends all elements of the specified array. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#get(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the value at a specified index. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#size()()` Returns the current size of the array. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#toArray()()` Copies the current values into a newly allocated primitive array. |

## Public constructors

### LongArray

```
LongArray()
```

### LongArray

```
LongArray(initialCapacity: Int)
```

| Parameters |
|---|---|
| `initialCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The initial capacity of the array. |

## Public functions

### add

```
fun add(value: Long): Unit
```

Appends a value.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The value to append. |

### addAll

```
fun addAll(values: LongArray<Long>!): Unit
```

Appends all elements of the specified array.

| Parameters |
|---|---|
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | The array whose elements are to be added. |

### get

```
fun get(index: Int): Long
```

Returns the value at a specified index.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The corresponding value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException.html` | If the index is less than zero, or greater than or equal to `https://developer.android.com/reference/kotlin/androidx/media3/common/util/LongArray#size()`. |

### size

```
fun size(): Int
```

Returns the current size of the array.

### toArray

```
fun toArray(): Array<Long>!
```

Copies the current values into a newly allocated primitive array.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | The primitive array containing the copied values. |