Package com.google.protobuf
Class ProtobufArrayList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- com.google.protobuf.AbstractProtobufList<E>
-
- com.google.protobuf.ProtobufArrayList<E>
-
- All Implemented Interfaces:
Internal.ProtobufList<E>
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,java.util.RandomAccess
final class ProtobufArrayList<E> extends AbstractProtobufList<E> implements java.util.RandomAccess
ImplementsInternal.ProtobufList
for non-primitive andString
types.
-
-
Field Summary
Fields Modifier and Type Field Description private E[]
array
private static java.lang.Object[]
EMPTY_ARRAY
private static ProtobufArrayList<java.lang.Object>
EMPTY_LIST
private int
size
-
Fields inherited from class com.google.protobuf.AbstractProtobufList
DEFAULT_CAPACITY
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
ProtobufArrayList()
private
ProtobufArrayList(E[] array, int size, boolean isMutable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E element)
boolean
add(E element)
private static <E> E[]
createArray(int capacity)
static <E> ProtobufArrayList<E>
emptyList()
(package private) void
ensureCapacity(int minCapacity)
Ensures the backing array can fit at least minCapacity elements.private void
ensureIndexInRange(int index)
E
get(int index)
private static int
growSize(int previousSize)
private java.lang.String
makeOutOfBoundsExceptionMessage(int index)
ProtobufArrayList<E>
mutableCopyWithCapacity(int capacity)
Returns a mutable clone of this list with the specified capacity.E
remove(int index)
E
set(int index, E element)
int
size()
-
Methods inherited from class com.google.protobuf.AbstractProtobufList
addAll, addAll, clear, ensureIsMutable, equals, hashCode, isModifiable, makeImmutable, remove, removeAll, retainAll
-
Methods inherited from class java.util.AbstractList
indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArray, toString
-
-
-
-
Field Detail
-
EMPTY_ARRAY
private static final java.lang.Object[] EMPTY_ARRAY
-
EMPTY_LIST
private static final ProtobufArrayList<java.lang.Object> EMPTY_LIST
-
array
private E[] array
-
size
private int size
-
-
Constructor Detail
-
ProtobufArrayList
ProtobufArrayList()
-
ProtobufArrayList
private ProtobufArrayList(E[] array, int size, boolean isMutable)
-
-
Method Detail
-
emptyList
public static <E> ProtobufArrayList<E> emptyList()
-
mutableCopyWithCapacity
public ProtobufArrayList<E> mutableCopyWithCapacity(int capacity)
Description copied from interface:Internal.ProtobufList
Returns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacity
in interfaceInternal.ProtobufList<E>
-
add
public boolean add(E element)
- Specified by:
add
in interfacejava.util.Collection<E>
- Specified by:
add
in interfacejava.util.List<E>
- Overrides:
add
in classAbstractProtobufList<E>
-
growSize
private static int growSize(int previousSize)
-
add
public void add(int index, E element)
- Specified by:
add
in interfacejava.util.List<E>
- Overrides:
add
in classAbstractProtobufList<E>
-
get
public E get(int index)
-
remove
public E remove(int index)
- Specified by:
remove
in interfacejava.util.List<E>
- Overrides:
remove
in classAbstractProtobufList<E>
-
set
public E set(int index, E element)
- Specified by:
set
in interfacejava.util.List<E>
- Overrides:
set
in classAbstractProtobufList<E>
-
size
public int size()
-
ensureCapacity
void ensureCapacity(int minCapacity)
Ensures the backing array can fit at least minCapacity elements.
-
createArray
private static <E> E[] createArray(int capacity)
-
ensureIndexInRange
private void ensureIndexInRange(int index)
-
makeOutOfBoundsExceptionMessage
private java.lang.String makeOutOfBoundsExceptionMessage(int index)
-
-