Package com.google.protobuf
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 LongArrayList
private int
The size of the list distinct from the length of the array.Fields inherited from class com.google.protobuf.AbstractProtobufList
DEFAULT_CAPACITY
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Constructs a new mutableLongArrayList
with default capacity.private
LongArrayList
(long[] other, int size) Constructs a new mutableLongArrayList
containing the same elements asother
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(Collection<? extends Long> collection) private void
addLong
(int index, long element) Likeadd(int, Long)
but more efficient in that it doesn't box the element.void
addLong
(long element) Likeadd(Long)
but more efficient in that it doesn't box the element.boolean
static LongArrayList
private void
ensureIndexInRange
(int index) Ensures that the providedindex
is within the range of[0, size]
.boolean
get
(int index) long
getLong
(int index) LikeList.get(int)
but more efficient in that it doesn't box the returned value.int
hashCode()
int
private String
makeOutOfBoundsExceptionMessage
(int index) mutableCopyWithCapacity
(int capacity) Returns a mutable clone of this list with the specified capacity.remove
(int index) protected void
removeRange
(int fromIndex, int toIndex) long
setLong
(int index, long element) LikeList.set(int, Object)
but more efficient in that it doesn't box the element.int
size()
Methods inherited from class com.google.protobuf.AbstractProtobufList
addAll, clear, ensureIsMutable, isModifiable, makeImmutable, remove, removeAll, retainAll
Methods inherited from class java.util.AbstractList
iterator, lastIndexOf, listIterator, listIterator, subList
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface com.google.protobuf.Internal.ProtobufList
isModifiable, makeImmutable
Methods inherited from interface java.util.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_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 mutableLongArrayList
with default capacity. -
LongArrayList
private LongArrayList(long[] other, int size) Constructs a new mutableLongArrayList
containing the same elements asother
.
-
-
Method Details
-
emptyList
-
removeRange
protected void removeRange(int fromIndex, int toIndex) - Overrides:
removeRange
in classAbstractList<Long>
-
equals
- Specified by:
equals
in interfaceCollection<Long>
- Specified by:
equals
in interfaceList<Long>
- Overrides:
equals
in classAbstractProtobufList<Long>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<Long>
- Specified by:
hashCode
in interfaceList<Long>
- Overrides:
hashCode
in classAbstractProtobufList<Long>
-
mutableCopyWithCapacity
Description copied from interface:Internal.LongList
Returns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacity
in interfaceInternal.LongList
- Specified by:
mutableCopyWithCapacity
in interfaceInternal.ProtobufList<Long>
-
get
-
getLong
public long getLong(int index) Description copied from interface:Internal.LongList
LikeList.get(int)
but more efficient in that it doesn't box the returned value.- Specified by:
getLong
in interfaceInternal.LongList
-
indexOf
-
contains
- Specified by:
contains
in interfaceCollection<Long>
- Specified by:
contains
in interfaceList<Long>
- Overrides:
contains
in classAbstractCollection<Long>
-
size
public int size()- Specified by:
size
in interfaceCollection<Long>
- Specified by:
size
in interfaceList<Long>
- Specified by:
size
in classAbstractCollection<Long>
-
set
-
setLong
public long setLong(int index, long element) Description copied from interface:Internal.LongList
LikeList.set(int, Object)
but more efficient in that it doesn't box the element.- Specified by:
setLong
in interfaceInternal.LongList
-
add
- Specified by:
add
in interfaceCollection<Long>
- Specified by:
add
in interfaceList<Long>
- Overrides:
add
in classAbstractProtobufList<Long>
-
add
-
addLong
public void addLong(long element) Likeadd(Long)
but more efficient in that it doesn't box the element.- Specified by:
addLong
in 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:
addAll
in interfaceCollection<Long>
- Specified by:
addAll
in interfaceList<Long>
- Overrides:
addAll
in classAbstractProtobufList<Long>
-
remove
-
ensureIndexInRange
private void ensureIndexInRange(int index) Ensures that the providedindex
is within the range of[0, size]
. Throws anIndexOutOfBoundsException
if it is not.- Parameters:
index
- the index to verify is in range
-
makeOutOfBoundsExceptionMessage
-