Package com.google.protobuf
Class LongArrayList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- com.google.protobuf.AbstractProtobufList<java.lang.Long>
-
- com.google.protobuf.LongArrayList
-
- All Implemented Interfaces:
Internal.LongList,Internal.ProtobufList<java.lang.Long>,PrimitiveNonBoxingCollection,java.lang.Iterable<java.lang.Long>,java.util.Collection<java.lang.Long>,java.util.List<java.lang.Long>,java.util.RandomAccess
final class LongArrayList extends AbstractProtobufList<java.lang.Long> implements Internal.LongList, java.util.RandomAccess, PrimitiveNonBoxingCollection
An implementation ofInternal.LongListon top of a primitive array.
-
-
Field Summary
Fields Modifier and Type Field Description private long[]arrayThe backing store for the list.private static LongArrayListEMPTY_LISTprivate intsizeThe size of the list distinct from the length of the array.-
Fields inherited from class com.google.protobuf.AbstractProtobufList
DEFAULT_CAPACITY
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)LongArrayList()Constructs a new mutableLongArrayListwith default capacity.privateLongArrayList(long[] other, int size, boolean isMutable)Constructs a new mutableLongArrayListcontaining the same elements asother.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Long element)booleanadd(java.lang.Long element)booleanaddAll(java.util.Collection<? extends java.lang.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.booleancontains(java.lang.Object element)static LongArrayListemptyList()private voidensureIndexInRange(int index)Ensures that the providedindexis within the range of[0, size].booleanequals(java.lang.Object o)java.lang.Longget(int index)longgetLong(int index)LikeList.get(int)but more efficient in that it doesn't box the returned value.inthashCode()intindexOf(java.lang.Object element)private java.lang.StringmakeOutOfBoundsExceptionMessage(int index)Internal.LongListmutableCopyWithCapacity(int capacity)Returns a mutable clone of this list with the specified capacity.java.lang.Longremove(int index)protected voidremoveRange(int fromIndex, int toIndex)java.lang.Longset(int index, java.lang.Long element)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 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 com.google.protobuf.Internal.ProtobufList
isModifiable, makeImmutable
-
-
-
-
Field Detail
-
EMPTY_LIST
private static final LongArrayList EMPTY_LIST
-
array
private long[] array
The backing store for the list.
-
size
private int size
The size of the list distinct from the length of the array. That is, it is the number of elements set in the list.
-
-
Method Detail
-
emptyList
public static LongArrayList emptyList()
-
removeRange
protected void removeRange(int fromIndex, int toIndex)- Overrides:
removeRangein classjava.util.AbstractList<java.lang.Long>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Collection<java.lang.Long>- Specified by:
equalsin interfacejava.util.List<java.lang.Long>- Overrides:
equalsin classAbstractProtobufList<java.lang.Long>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<java.lang.Long>- Specified by:
hashCodein interfacejava.util.List<java.lang.Long>- Overrides:
hashCodein classAbstractProtobufList<java.lang.Long>
-
mutableCopyWithCapacity
public Internal.LongList mutableCopyWithCapacity(int capacity)
Description copied from interface:Internal.LongListReturns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacityin interfaceInternal.LongList- Specified by:
mutableCopyWithCapacityin interfaceInternal.ProtobufList<java.lang.Long>
-
get
public java.lang.Long get(int index)
- Specified by:
getin interfacejava.util.List<java.lang.Long>- Specified by:
getin classjava.util.AbstractList<java.lang.Long>
-
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
public int indexOf(java.lang.Object element)
- Specified by:
indexOfin interfacejava.util.List<java.lang.Long>- Overrides:
indexOfin classjava.util.AbstractList<java.lang.Long>
-
contains
public boolean contains(java.lang.Object element)
- Specified by:
containsin interfacejava.util.Collection<java.lang.Long>- Specified by:
containsin interfacejava.util.List<java.lang.Long>- Overrides:
containsin classjava.util.AbstractCollection<java.lang.Long>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<java.lang.Long>- Specified by:
sizein interfacejava.util.List<java.lang.Long>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Long>
-
set
public java.lang.Long set(int index, java.lang.Long element)- Specified by:
setin interfacejava.util.List<java.lang.Long>- Overrides:
setin classAbstractProtobufList<java.lang.Long>
-
setLong
public long setLong(int index, long element)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
public boolean add(java.lang.Long element)
- Specified by:
addin interfacejava.util.Collection<java.lang.Long>- Specified by:
addin interfacejava.util.List<java.lang.Long>- Overrides:
addin classAbstractProtobufList<java.lang.Long>
-
add
public void add(int index, java.lang.Long element)- Specified by:
addin interfacejava.util.List<java.lang.Long>- Overrides:
addin classAbstractProtobufList<java.lang.Long>
-
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
public boolean addAll(java.util.Collection<? extends java.lang.Long> collection)
- Specified by:
addAllin interfacejava.util.Collection<java.lang.Long>- Specified by:
addAllin interfacejava.util.List<java.lang.Long>- Overrides:
addAllin classAbstractProtobufList<java.lang.Long>
-
remove
public java.lang.Long remove(int index)
- Specified by:
removein interfacejava.util.List<java.lang.Long>- Overrides:
removein classAbstractProtobufList<java.lang.Long>
-
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
private java.lang.String makeOutOfBoundsExceptionMessage(int index)
-
-