Package com.google.protobuf
Class IntArrayList
- All Implemented Interfaces:
Internal.IntList
,Internal.ProtobufList<Integer>
,PrimitiveNonBoxingCollection
,Iterable<Integer>
,Collection<Integer>
,List<Integer>
,RandomAccess
,SequencedCollection<Integer>
final class IntArrayList
extends AbstractProtobufList<Integer>
implements Internal.IntList, RandomAccess, PrimitiveNonBoxingCollection
An implementation of
Internal.IntList
on top of a primitive array.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
The backing store for the list.private static final int[]
private static final IntArrayList
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 mutableIntArrayList
with default capacity.private
IntArrayList
(int[] other, int size, boolean isMutable) Constructs a new mutableIntArrayList
containing the same elements asother
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(Collection<? extends Integer> collection) void
addInt
(int element) Likeadd(Integer)
but more efficient in that it doesn't box the element.private void
addInt
(int index, int element) Likeadd(int, Integer)
but more efficient in that it doesn't box the element.boolean
static IntArrayList
(package private) void
ensureCapacity
(int minCapacity) Ensures the backing array can fit at least minCapacity elements.private void
ensureIndexInRange
(int index) Ensures that the providedindex
is within the range of[0, size]
.boolean
get
(int index) int
getInt
(int index) LikeList.get(int)
but more efficient in that it doesn't box the returned value.private static int
growSize
(int previousSize) 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) int
setInt
(int index, int 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_ARRAY
private static final int[] EMPTY_ARRAY -
EMPTY_LIST
-
array
private int[] 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
-
IntArrayList
IntArrayList()Constructs a new mutableIntArrayList
with default capacity. -
IntArrayList
private IntArrayList(int[] other, int size, boolean isMutable) Constructs a new mutableIntArrayList
containing the same elements asother
.
-
-
Method Details
-
emptyList
-
removeRange
protected void removeRange(int fromIndex, int toIndex) - Overrides:
removeRange
in classAbstractList<Integer>
-
equals
- Specified by:
equals
in interfaceCollection<Integer>
- Specified by:
equals
in interfaceList<Integer>
- Overrides:
equals
in classAbstractProtobufList<Integer>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<Integer>
- Specified by:
hashCode
in interfaceList<Integer>
- Overrides:
hashCode
in classAbstractProtobufList<Integer>
-
mutableCopyWithCapacity
Description copied from interface:Internal.IntList
Returns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacity
in interfaceInternal.IntList
- Specified by:
mutableCopyWithCapacity
in interfaceInternal.ProtobufList<Integer>
-
get
-
getInt
public int getInt(int index) Description copied from interface:Internal.IntList
LikeList.get(int)
but more efficient in that it doesn't box the returned value.- Specified by:
getInt
in interfaceInternal.IntList
-
indexOf
-
contains
- Specified by:
contains
in interfaceCollection<Integer>
- Specified by:
contains
in interfaceList<Integer>
- Overrides:
contains
in classAbstractCollection<Integer>
-
size
public int size()- Specified by:
size
in interfaceCollection<Integer>
- Specified by:
size
in interfaceList<Integer>
- Specified by:
size
in classAbstractCollection<Integer>
-
set
-
setInt
public int setInt(int index, int element) Description copied from interface:Internal.IntList
LikeList.set(int, Object)
but more efficient in that it doesn't box the element.- Specified by:
setInt
in interfaceInternal.IntList
-
add
- Specified by:
add
in interfaceCollection<Integer>
- Specified by:
add
in interfaceList<Integer>
- Overrides:
add
in classAbstractProtobufList<Integer>
-
add
-
addInt
public void addInt(int element) Likeadd(Integer)
but more efficient in that it doesn't box the element.- Specified by:
addInt
in interfaceInternal.IntList
-
addInt
private void addInt(int index, int element) Likeadd(int, Integer)
but more efficient in that it doesn't box the element. -
addAll
- Specified by:
addAll
in interfaceCollection<Integer>
- Specified by:
addAll
in interfaceList<Integer>
- Overrides:
addAll
in classAbstractProtobufList<Integer>
-
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 providedindex
is within the range of[0, size]
. Throws anIndexOutOfBoundsException
if it is not.- Parameters:
index
- the index to verify is in range
-
makeOutOfBoundsExceptionMessage
-