Package com.google.protobuf
Class DoubleArrayList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- com.google.protobuf.AbstractProtobufList<java.lang.Double>
-
- com.google.protobuf.DoubleArrayList
-
- All Implemented Interfaces:
Internal.DoubleList,Internal.ProtobufList<java.lang.Double>,PrimitiveNonBoxingCollection,java.lang.Iterable<java.lang.Double>,java.util.Collection<java.lang.Double>,java.util.List<java.lang.Double>,java.util.RandomAccess
final class DoubleArrayList extends AbstractProtobufList<java.lang.Double> implements Internal.DoubleList, java.util.RandomAccess, PrimitiveNonBoxingCollection
An implementation ofInternal.DoubleListon top of a primitive array.
-
-
Field Summary
Fields Modifier and Type Field Description private double[]arrayThe backing store for the list.private static double[]EMPTY_ARRAYprivate static DoubleArrayListEMPTY_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)DoubleArrayList()Constructs a new mutableDoubleArrayListwith default capacity.privateDoubleArrayList(double[] other, int size, boolean isMutable)Constructs a new mutableDoubleArrayListcontaining the same elements asother.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Double element)booleanadd(java.lang.Double element)booleanaddAll(java.util.Collection<? extends java.lang.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.booleancontains(java.lang.Object element)static DoubleArrayListemptyList()(package private) voidensureCapacity(int minCapacity)Ensures the backing array can fit at least minCapacity elements.private voidensureIndexInRange(int index)Ensures that the providedindexis within the range of[0, size].booleanequals(java.lang.Object o)java.lang.Doubleget(int index)doublegetDouble(int index)LikeList.get(int)but more efficient in that it doesn't box the returned value.private static intgrowSize(int previousSize)inthashCode()intindexOf(java.lang.Object element)private java.lang.StringmakeOutOfBoundsExceptionMessage(int index)Internal.DoubleListmutableCopyWithCapacity(int capacity)Returns a mutable clone of this list with the specified capacity.java.lang.Doubleremove(int index)protected voidremoveRange(int fromIndex, int toIndex)java.lang.Doubleset(int index, java.lang.Double element)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, 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_ARRAY
private static final double[] EMPTY_ARRAY
-
EMPTY_LIST
private static final DoubleArrayList EMPTY_LIST
-
array
private double[] 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 DoubleArrayList emptyList()
-
removeRange
protected void removeRange(int fromIndex, int toIndex)- Overrides:
removeRangein classjava.util.AbstractList<java.lang.Double>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Collection<java.lang.Double>- Specified by:
equalsin interfacejava.util.List<java.lang.Double>- Overrides:
equalsin classAbstractProtobufList<java.lang.Double>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<java.lang.Double>- Specified by:
hashCodein interfacejava.util.List<java.lang.Double>- Overrides:
hashCodein classAbstractProtobufList<java.lang.Double>
-
mutableCopyWithCapacity
public Internal.DoubleList mutableCopyWithCapacity(int capacity)
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<java.lang.Double>
-
get
public java.lang.Double get(int index)
- Specified by:
getin interfacejava.util.List<java.lang.Double>- Specified by:
getin classjava.util.AbstractList<java.lang.Double>
-
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
public int indexOf(java.lang.Object element)
- Specified by:
indexOfin interfacejava.util.List<java.lang.Double>- Overrides:
indexOfin classjava.util.AbstractList<java.lang.Double>
-
contains
public boolean contains(java.lang.Object element)
- Specified by:
containsin interfacejava.util.Collection<java.lang.Double>- Specified by:
containsin interfacejava.util.List<java.lang.Double>- Overrides:
containsin classjava.util.AbstractCollection<java.lang.Double>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<java.lang.Double>- Specified by:
sizein interfacejava.util.List<java.lang.Double>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Double>
-
set
public java.lang.Double set(int index, java.lang.Double element)- Specified by:
setin interfacejava.util.List<java.lang.Double>- Overrides:
setin classAbstractProtobufList<java.lang.Double>
-
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
public boolean add(java.lang.Double element)
- Specified by:
addin interfacejava.util.Collection<java.lang.Double>- Specified by:
addin interfacejava.util.List<java.lang.Double>- Overrides:
addin classAbstractProtobufList<java.lang.Double>
-
add
public void add(int index, java.lang.Double element)- Specified by:
addin interfacejava.util.List<java.lang.Double>- Overrides:
addin classAbstractProtobufList<java.lang.Double>
-
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
public boolean addAll(java.util.Collection<? extends java.lang.Double> collection)
- Specified by:
addAllin interfacejava.util.Collection<java.lang.Double>- Specified by:
addAllin interfacejava.util.List<java.lang.Double>- Overrides:
addAllin classAbstractProtobufList<java.lang.Double>
-
remove
public java.lang.Double remove(int index)
- Specified by:
removein interfacejava.util.List<java.lang.Double>- Overrides:
removein classAbstractProtobufList<java.lang.Double>
-
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 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)
-
-