Class LongArrayList
- All Implemented Interfaces:
Internal.LongList, Internal.ProtobufList<Long>, PrimitiveNonBoxingCollection, Iterable<Long>, Collection<Long>, List<Long>, RandomAccess, SequencedCollection<Long>
final class LongArrayList
extends AbstractProtobufList<Long>
implements Internal.LongList, RandomAccess, PrimitiveNonBoxingCollection
An implementation of
Internal.LongList on top of a primitive array.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long[]The backing store for the list.private static final long[]private static final LongArrayListprivate intThe size of the list distinct from the length of the array.Fields inherited from class AbstractProtobufList
DEFAULT_CAPACITYFields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Constructs a new mutableLongArrayListwith default capacity.privateLongArrayList(long[] other, int size, boolean isMutable) Constructs a new mutableLongArrayListcontaining the same elements asother.(package private)LongArrayList(LongArrayList other, boolean isMutable) Constructs a new mutableLongArrayListcontaining the same elements asother. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(Collection<? extends Long> collection) private voidaddLong(int index, long element) Likeadd(int, Long)but more efficient in that it doesn't box the element.voidaddLong(long element) Likeadd(Long)but more efficient in that it doesn't box the element.booleanstatic LongArrayList(package private) voidensureCapacity(int minCapacity) Ensures the backing array can fit at least minCapacity elements.private voidensureIndexInRange(int index) Ensures that the providedindexis within the range of[0, size].booleanget(int index) longgetLong(int index) LikeList.get(int)but more efficient in that it doesn't box the returned value.private static intgrowSize(int previousSize) inthashCode()intprivate StringmakeOutOfBoundsExceptionMessage(int index) mutableCopyWithCapacity(int capacity) Returns a mutable clone of this list with the specified capacity.remove(int index) protected voidremoveRange(int fromIndex, int toIndex) longsetLong(int index, long element) LikeList.set(int, Object)but more efficient in that it doesn't box the element.intsize()Methods inherited from class AbstractProtobufList
addAll, clear, ensureIsMutable, isModifiable, makeImmutable, remove, removeAll, retainAllMethods inherited from class AbstractList
iterator, lastIndexOf, listIterator, listIterator, subListMethods inherited from class AbstractCollection
containsAll, isEmpty, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface Internal.ProtobufList
isModifiable, makeImmutableMethods inherited from interface List
addAll, addFirst, addLast, clear, containsAll, getFirst, getLast, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList, toArray, toArray
-
Field Details
-
EMPTY_ARRAY
private static final long[] EMPTY_ARRAY -
EMPTY_LIST
-
array
private long[] arrayThe backing store for the list. -
size
private int sizeThe size of the list distinct from the length of the array. That is, it is the number of elements set in the list.
-
-
Constructor Details
-
LongArrayList
LongArrayList()Constructs a new mutableLongArrayListwith default capacity. -
LongArrayList
private LongArrayList(long[] other, int size, boolean isMutable) Constructs a new mutableLongArrayListcontaining the same elements asother. -
LongArrayList
LongArrayList(LongArrayList other, boolean isMutable) Constructs a new mutableLongArrayListcontaining the same elements asother.
-
-
Method Details
-
emptyList
-
removeRange
protected void removeRange(int fromIndex, int toIndex) - Overrides:
removeRangein classAbstractList<Long>
-
equals
- Specified by:
equalsin interfaceCollection<Long>- Specified by:
equalsin interfaceList<Long>- Overrides:
equalsin classAbstractProtobufList<Long>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<Long>- Specified by:
hashCodein interfaceList<Long>- Overrides:
hashCodein classAbstractProtobufList<Long>
-
mutableCopyWithCapacity
Description copied from interface:Internal.ProtobufListReturns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacityin interfaceInternal.LongList- Specified by:
mutableCopyWithCapacityin interfaceInternal.ProtobufList<Long>
-
get
-
getLong
public long getLong(int index) Description copied from interface:Internal.LongListLikeList.get(int)but more efficient in that it doesn't box the returned value.- Specified by:
getLongin interfaceInternal.LongList
-
indexOf
-
contains
- Specified by:
containsin interfaceCollection<Long>- Specified by:
containsin interfaceList<Long>- Overrides:
containsin classAbstractCollection<Long>
-
size
public int size()- Specified by:
sizein interfaceCollection<Long>- Specified by:
sizein interfaceList<Long>- Specified by:
sizein classAbstractCollection<Long>
-
set
-
setLong
Description copied from interface:Internal.LongListLikeList.set(int, Object)but more efficient in that it doesn't box the element.- Specified by:
setLongin interfaceInternal.LongList
-
add
- Specified by:
addin interfaceCollection<Long>- Specified by:
addin interfaceList<Long>- Overrides:
addin classAbstractProtobufList<Long>
-
add
-
addLong
public void addLong(long element) Likeadd(Long)but more efficient in that it doesn't box the element.- Specified by:
addLongin interfaceInternal.LongList
-
addLong
private void addLong(int index, long element) Likeadd(int, Long)but more efficient in that it doesn't box the element. -
addAll
- Specified by:
addAllin interfaceCollection<Long>- Specified by:
addAllin interfaceList<Long>- Overrides:
addAllin classAbstractProtobufList<Long>
-
remove
-
ensureCapacity
void ensureCapacity(int minCapacity) Ensures the backing array can fit at least minCapacity elements. -
growSize
private static int growSize(int previousSize) -
ensureIndexInRange
private void ensureIndexInRange(int index) Ensures that the providedindexis within the range of[0, size]. Throws anIndexOutOfBoundsExceptionif it is not.- Parameters:
index- the index to verify is in range
-
makeOutOfBoundsExceptionMessage
-