Package com.google.protobuf
Class DoubleArrayList
- All Implemented Interfaces:
Internal.DoubleList
,Internal.ProtobufList<Double>
,PrimitiveNonBoxingCollection
,Iterable<Double>
,Collection<Double>
,List<Double>
,RandomAccess
,SequencedCollection<Double>
final class DoubleArrayList
extends AbstractProtobufList<Double>
implements Internal.DoubleList, RandomAccess, PrimitiveNonBoxingCollection
An implementation of
Internal.DoubleList
on top of a primitive array.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double[]
The backing store for the list.private static final DoubleArrayList
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 mutableDoubleArrayList
with default capacity.private
DoubleArrayList
(double[] other, int size) Constructs a new mutableDoubleArrayList
containing the same elements asother
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(Collection<? extends Double> collection) void
addDouble
(double element) Likeadd(Double)
but more efficient in that it doesn't box the element.private void
addDouble
(int index, double element) Likeadd(int, Double)
but more efficient in that it doesn't box the element.boolean
static DoubleArrayList
private void
ensureIndexInRange
(int index) Ensures that the providedindex
is within the range of[0, size]
.boolean
get
(int index) double
getDouble
(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) double
setDouble
(int index, double 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 double[] 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
-
DoubleArrayList
DoubleArrayList()Constructs a new mutableDoubleArrayList
with default capacity. -
DoubleArrayList
private DoubleArrayList(double[] other, int size) Constructs a new mutableDoubleArrayList
containing the same elements asother
.
-
-
Method Details
-
emptyList
-
removeRange
protected void removeRange(int fromIndex, int toIndex) - Overrides:
removeRange
in classAbstractList<Double>
-
equals
- Specified by:
equals
in interfaceCollection<Double>
- Specified by:
equals
in interfaceList<Double>
- Overrides:
equals
in classAbstractProtobufList<Double>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<Double>
- Specified by:
hashCode
in interfaceList<Double>
- Overrides:
hashCode
in classAbstractProtobufList<Double>
-
mutableCopyWithCapacity
Description copied from interface:Internal.DoubleList
Returns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacity
in interfaceInternal.DoubleList
- Specified by:
mutableCopyWithCapacity
in interfaceInternal.ProtobufList<Double>
-
get
-
getDouble
public double getDouble(int index) Description copied from interface:Internal.DoubleList
LikeList.get(int)
but more efficient in that it doesn't box the returned value.- Specified by:
getDouble
in interfaceInternal.DoubleList
-
indexOf
-
contains
- Specified by:
contains
in interfaceCollection<Double>
- Specified by:
contains
in interfaceList<Double>
- Overrides:
contains
in classAbstractCollection<Double>
-
size
public int size()- Specified by:
size
in interfaceCollection<Double>
- Specified by:
size
in interfaceList<Double>
- Specified by:
size
in classAbstractCollection<Double>
-
set
-
setDouble
public double setDouble(int index, double element) Description copied from interface:Internal.DoubleList
LikeList.set(int, Object)
but more efficient in that it doesn't box the element.- Specified by:
setDouble
in interfaceInternal.DoubleList
-
add
- Specified by:
add
in interfaceCollection<Double>
- Specified by:
add
in interfaceList<Double>
- Overrides:
add
in classAbstractProtobufList<Double>
-
add
-
addDouble
public void addDouble(double element) Likeadd(Double)
but more efficient in that it doesn't box the element.- Specified by:
addDouble
in interfaceInternal.DoubleList
-
addDouble
private void addDouble(int index, double element) Likeadd(int, Double)
but more efficient in that it doesn't box the element. -
addAll
- Specified by:
addAll
in interfaceCollection<Double>
- Specified by:
addAll
in interfaceList<Double>
- Overrides:
addAll
in classAbstractProtobufList<Double>
-
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
-