Methods Summary |
---|
public void | add(long value)Appends the specified value to the end of this array.
add(mSize, value);
|
public void | add(int index, long value)Inserts a value at the specified position in this array.
if (index < 0 || index > mSize) {
throw new IndexOutOfBoundsException();
}
ensureCapacity(1);
if (mSize - index != 0) {
System.arraycopy(mValues, index, mValues, index + 1, mSize - index);
}
mValues[index] = value;
mSize++;
|
public void | addAll(android.util.LongArray values)Adds the values in the specified array to this array.
final int count = values.mSize;
ensureCapacity(count);
System.arraycopy(values.mValues, 0, mValues, mSize, count);
mSize += count;
|
public void | clear()Removes all values from this array.
mSize = 0;
|
public android.util.LongArray | clone()
LongArray clone = null;
try {
clone = (LongArray) super.clone();
clone.mValues = mValues.clone();
} catch (CloneNotSupportedException cnse) {
/* ignore */
}
return clone;
|
private void | ensureCapacity(int count)Ensures capacity to append at least count values.
final int currentSize = mSize;
final int minCapacity = currentSize + count;
if (minCapacity >= mValues.length) {
final int targetCap = currentSize + (currentSize < (MIN_CAPACITY_INCREMENT / 2) ?
MIN_CAPACITY_INCREMENT : currentSize >> 1);
final int newCapacity = targetCap > minCapacity ? targetCap : minCapacity;
final long[] newValues = ArrayUtils.newUnpaddedLongArray(newCapacity);
System.arraycopy(mValues, 0, newValues, 0, currentSize);
mValues = newValues;
}
|
public long | get(int index)Returns the value at the specified position in this array.
if (index >= mSize) {
throw new ArrayIndexOutOfBoundsException(mSize, index);
}
return mValues[index];
|
public int | indexOf(long value)Returns the index of the first occurrence of the specified value in this
array, or -1 if this array does not contain the value.
final int n = mSize;
for (int i = 0; i < n; i++) {
if (mValues[i] == value) {
return i;
}
}
return -1;
|
public void | remove(int index)Removes the value at the specified index from this array.
if (index >= mSize) {
throw new ArrayIndexOutOfBoundsException(mSize, index);
}
System.arraycopy(mValues, index + 1, mValues, index, mSize - index - 1);
mSize--;
|
public int | size()Returns the number of values in this array.
return mSize;
|