Stay organized with collections Save and categorize content based on your preferences.

LongArray

@UnstableApi
public final class LongArray


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

Summary

Public constructors

LongArray(int initialCapacity)

Public methods

void
add(long value)

Appends a value.

long
get(int index)

Returns the value at a specified index.

int

Returns the current size of the array.

long[]

Copies the current values into a newly allocated primitive array.

Public constructors

LongArray

public LongArray()

LongArray

public LongArray(int initialCapacity)
Parameters
int initialCapacity

The initial capacity of the array.

Public methods

add

public void add(long value)

Appends a value.

Parameters
long value

The value to append.

get

public long get(int index)

Returns the value at a specified index.

Parameters
int index

The index.

Returns
long

The corresponding value.

Throws
java.lang.IndexOutOfBoundsException java.lang.IndexOutOfBoundsException

If the index is less than zero, or greater than or equal to size.

size

public int size()

Returns the current size of the array.

toArray

public long[] toArray()

Copies the current values into a newly allocated primitive array.

Returns
long[]

The primitive array containing the copied values.