public class ArrayDoubleCollection extends AbstractDoubleCollection implements java.lang.Cloneable
DoubleCollection for
primitive double elements.
This collection implementation allows multiple copies of the same value to be added. Internally, it uses an array, and behaves much like a list.
This class implements Collection allowing
seamless integration with other APIs.
Add, Remove and Clear are supported.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ArrayDoubleCollection.PIterator
Iterator.
|
| Constructor and Description |
|---|
ArrayDoubleCollection()
Constructor.
|
ArrayDoubleCollection(java.util.Collection<?> coll)
Constructs a new collection by copying values from another collection.
|
ArrayDoubleCollection(double[] values)
Constructor that copies the specified values.
|
ArrayDoubleCollection(int initialSize)
Constructor that defines an initial size for the internal storage array.
|
ArrayDoubleCollection(java.util.Iterator<java.lang.Double> it)
Constructs a new collection by copying values from an iterator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(double value)
Adds a primitive value to this collection.
|
boolean |
addAll(double[] values)
Adds an array of primitive values to this collection.
|
boolean |
addAll(DoubleCollection values)
Adds a collection of primitive values to this collection.
|
protected void |
arrayCopy(int fromIndex,
double[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
void |
clear()
Clears the collection of all elements.
|
java.lang.Object |
clone()
Clone implementation that calls Object clone().
|
boolean |
contains(double value)
Checks whether this collection contains a specified primitive value.
|
protected boolean |
doAdd(int index,
double[] values)
Internal implementation to add to this collection at the specified index.
|
protected void |
doRemoveIndex(int index)
Internal implementation to remove the element at the specified index.
|
protected void |
ensureCapacity(int reqCapacity)
Internal implementation to ensure that the internal storage array has
at least the specified size.
|
protected boolean |
isAddModifiable()
Are the add methods supported.
|
boolean |
isModifiable()
Checks whether the object can currently be modified.
|
protected boolean |
isRemoveModifiable()
Are the remove methods supported.
|
DoubleIterator |
iterator()
Gets an iterator over this collection capable of accessing the primitive values.
|
void |
optimize()
Optimizes the implementation.
|
int |
size()
Gets the current size of the collection.
|
add, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toArray, toArray, toDoubleArray, toDoubleArray, toObject, toPrimitive, toPrimitiveArray, toStringisEmptyequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisEmptypublic ArrayDoubleCollection()
public ArrayDoubleCollection(int initialSize)
initialSize - the initial size of the internal array, negative treated as zeropublic ArrayDoubleCollection(double[] values)
values - an array of values to copy, null treated as zero size arraypublic ArrayDoubleCollection(java.util.Collection<?> coll)
coll - a collection of values to copy, null treated as zero size collectionpublic ArrayDoubleCollection(java.util.Iterator<java.lang.Double> it)
it - an iterator of values to extract, null treated as zero size collectionpublic int size()
size in interface java.util.Collection<java.lang.Double>size in interface PrimitiveCollectable<java.lang.Double>public DoubleIterator iterator()
iterator in interface java.lang.Iterable<java.lang.Double>iterator in interface java.util.Collection<java.lang.Double>iterator in interface DoubleCollectioniterator in interface DoubleIterablepublic boolean add(double value)
add in interface DoubleCollectionadd in class AbstractDoubleCollectionvalue - the value to add to this collectiontrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if value is rejected by this collectionpublic void optimize()
This implementation changes the internal array to be the same size as the size of the collection.
optimize in interface PrimitiveCollectable<java.lang.Double>optimize in class AbstractPrimitiveCollectable<java.lang.Double>protected boolean isAddModifiable()
isAddModifiable in class AbstractDoubleCollectiontrueprotected boolean isRemoveModifiable()
isRemoveModifiable in class AbstractDoubleCollectiontruepublic boolean isModifiable()
isModifiable in interface PrimitiveCollectable<java.lang.Double>isModifiable in class AbstractDoubleCollectiontruepublic boolean contains(double value)
This implementation uses the internal array directly.
contains in interface DoubleCollectioncontains in class AbstractDoubleCollectionvalue - the value to search fortrue if the value is foundpublic void clear()
This implementation resets the size, but does not reduce the internal storage array.
clear in interface java.util.Collection<java.lang.Double>clear in interface PrimitiveCollectable<java.lang.Double>clear in class AbstractDoubleCollectionpublic boolean addAll(double[] values)
addAll in interface DoubleCollectionaddAll in class AbstractDoubleCollectionvalues - the values to add to this collectiontrue if this collection was modified by this method callpublic boolean addAll(DoubleCollection values)
addAll in interface DoubleCollectionaddAll in class AbstractDoubleCollectionvalues - the values to add to this collection, null treated as empty collectiontrue if this collection was modified by this method callpublic java.lang.Object clone()
clone in interface PrimitiveCollectable<java.lang.Double>clone in class AbstractPrimitiveCollectable<java.lang.Double>protected void arrayCopy(int fromIndex,
double[] dest,
int destIndex,
int size)
arrayCopy in class AbstractDoubleCollectionfromIndex - the index to start fromdest - the destination arraydestIndex - the destination start indexsize - the number of items to copyprotected boolean doAdd(int index,
double[] values)
index - the index to add at, validvalues - the array to add, not nullprotected void doRemoveIndex(int index)
index - the index, validprotected void ensureCapacity(int reqCapacity)
reqCapacity - the amount to expand toCopyright © 2005–2018 Joda.org. All rights reserved.