Package com.google.protobuf
Class DoubleArrayList
- All Implemented Interfaces:
Internal.DoubleList,Internal.ProtobufList<Double>,PrimitiveNonBoxingCollection,Iterable<Double>,Collection<Double>,List<Double>,RandomAccess
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 DoubleArrayListprivate intThe size of the list distinct from the length of the array.Fields inherited from class com.google.protobuf.AbstractProtobufList
DEFAULT_CAPACITYFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Constructs a new mutableDoubleArrayListwith default capacity.privateDoubleArrayList(double[] other, int size, boolean isMutable) Constructs a new mutableDoubleArrayListcontaining the same elements asother. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(Collection<? extends Double> collection) voidaddDouble(double element) Likeadd(Double)but more efficient in that it doesn't box the element.private voidaddDouble(int index, double element) Likeadd(int, Double)but more efficient in that it doesn't box the element.booleanstatic DoubleArrayListprivate voidensureIndexInRange(int index) Ensures that the providedindexis within the range of[0, size].booleanget(int index) doublegetDouble(int index) LikeList.get(int)but more efficient in that it doesn't box the returned value.inthashCode()intprivate StringmakeOutOfBoundsExceptionMessage(int index) mutableCopyWithCapacity(int capacity) Returns a mutable clone of this list with the specified capacity.remove(int index) protected voidremoveRange(int fromIndex, int toIndex) doublesetDouble(int index, double 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, retainAllMethods inherited from class java.util.AbstractList
iterator, lastIndexOf, listIterator, listIterator, subListMethods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.google.protobuf.Internal.ProtobufList
isModifiable, makeImmutableMethods inherited from interface java.util.List
addAll, clear, containsAll, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, 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 mutableDoubleArrayListwith default capacity. -
DoubleArrayList
private DoubleArrayList(double[] other, int size, boolean isMutable) Constructs a new mutableDoubleArrayListcontaining the same elements asother.
-
-
Method Details
-
emptyList
-
removeRange
protected void removeRange(int fromIndex, int toIndex) - Overrides:
removeRangein classAbstractList<Double>
-
equals
- Specified by:
equalsin interfaceCollection<Double>- Specified by:
equalsin interfaceList<Double>- Overrides:
equalsin classAbstractProtobufList<Double>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<Double>- Specified by:
hashCodein interfaceList<Double>- Overrides:
hashCodein classAbstractProtobufList<Double>
-
mutableCopyWithCapacity
Description copied from interface:Internal.DoubleListReturns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacityin interfaceInternal.DoubleList- Specified by:
mutableCopyWithCapacityin interfaceInternal.ProtobufList<Double>
-
get
-
getDouble
public double getDouble(int index) Description copied from interface:Internal.DoubleListLikeList.get(int)but more efficient in that it doesn't box the returned value.- Specified by:
getDoublein interfaceInternal.DoubleList
-
indexOf
-
contains
- Specified by:
containsin interfaceCollection<Double>- Specified by:
containsin interfaceList<Double>- Overrides:
containsin classAbstractCollection<Double>
-
size
public int size()- Specified by:
sizein interfaceCollection<Double>- Specified by:
sizein interfaceList<Double>- Specified by:
sizein classAbstractCollection<Double>
-
set
-
setDouble
public double setDouble(int index, double element) Description copied from interface:Internal.DoubleListLikeList.set(int, Object)but more efficient in that it doesn't box the element.- Specified by:
setDoublein interfaceInternal.DoubleList
-
add
- Specified by:
addin interfaceCollection<Double>- Specified by:
addin interfaceList<Double>- Overrides:
addin classAbstractProtobufList<Double>
-
add
-
addDouble
public void addDouble(double element) Likeadd(Double)but more efficient in that it doesn't box the element.- Specified by:
addDoublein 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:
addAllin interfaceCollection<Double>- Specified by:
addAllin interfaceList<Double>- Overrides:
addAllin classAbstractProtobufList<Double>
-
remove
-
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
-