public class DoubleArrayList
extends java.lang.Object
Like java.util.ArrayList, its underlying representation can grow dynamically. As well, it is not synchronized.
| Constructor and Description |
|---|
DoubleArrayList()
Constructs an empty DoubleArrayList so that its internal data array has size
10 and its standard capacity increment is zero.
|
DoubleArrayList(java.util.Collection c)
Constructs a DoubleArrayList containing the doubleValue() values of the
java.lang.Number objects in the specified collection, in the
order they are returned by the collection's iterator.
|
DoubleArrayList(double[] a)
Constructs a doubleArrayList containing the values contained in the
specified array, in the same order.
|
DoubleArrayList(int initialCapacity)
Constructs an empty DoubleArrayList with the specified initial capacity and
with its capacity increment equal to zero.
|
DoubleArrayList(int initialCapacity,
int capacityIncrement)
Constructs an empty DoubleArrayList with the specified initial capacity and
capacity increment.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(double element)
Appends the specified element to the end of this DoubleArrayList.
|
void |
add(int index,
double element)
Inserts the specified element at the specified position in this
DoubleArrayList.
|
boolean |
addAll(double[] a)
Appends all of the elements in the specified array to the end
of this DoubleArrayList, in the order of the array.
|
boolean |
addAll(DoubleArrayList v)
Appends all of the elements in the specified DoubleArrayList to the end
of this DoubleArrayList.
|
void |
addAll(int index,
double[] a)
Inserts all the elements in the specified array at the specified
position in this DoubleArrayList.
|
void |
addAll(int index,
DoubleArrayList v)
Inserts all of the elements in the specified DoubleArrayList into this
DoubleArrayList at the specified position.
|
void |
addElement(double element)
Adds the specified component to the end of this DoubleArrayList, increasing
its size by one.
|
int |
capacity()
Returns the current capacity of this DoubleArrayList.
|
void |
clear()
Removes all of the elements from this DoubleArrayList.
|
void |
clear(int index)
Clears all elements of this DoubleArraylist at index equal to or
greater than the specified index.
|
java.lang.Object |
clone()
Returns a clone of this DoubleArrayList.
|
boolean |
contains(double element)
Tests if the specified double is a component in this DoubleArrayList.
|
boolean |
containsAll(double[] a)
Returns true if this DoubleArrayList contains all of the elements in the
specified array.
|
boolean |
containsAll(DoubleArrayList v)
Returns true if this DoubleArrayList contains all of the elements in the
specified DoubleArrayList.
|
void |
copyInto(double[] a)
Copies the components of this DoubleArrayList into the specified array.
|
double |
elementAt(int index)
Returns the component at the specified index.
|
void |
ensureCapacity(int minCapacity)
Increases the capacity of this DoubleArrayList, if necessary, to ensure that
it can hold at least the number of components specified by the
minimum capacity argument.
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this DoubleArrayList for equality.
|
double |
firstElement()
Returns the first component (the item at index 0) of this DoubleArrayList.
|
double |
get(int index)
Returns the element at the specified position in this DoubleArrayList.
|
int |
hashCode()
Returns the hash code value for this DoubleArrayList.
|
int |
indexOf(double element)
Searches for the first occurrence of the given double; returns -1 if it
is not found.
|
int |
indexOf(double element,
int index)
Searches for the first occurence of the given double, beginning
the search at index; returns -1 if it is not found.
|
void |
insertElementAt(double element,
int index)
Inserts the specified double as a component in this DoubleArrayList at the
specified index.
|
boolean |
isEmpty()
Tests if this DoubleArrayList has no components.
|
double |
lastElement()
Returns the last component of the DoubleArrayList.
|
int |
lastIndexOf(double element)
Returns the index of the last occurrence of the specified double in
this DoubleArrayList; returns -1 if it is not found.
|
int |
lastIndexOf(double element,
int index)
Searches backwards for the specified double, starting from the
specified index, and returns its index, or -1 if not found.
|
boolean |
remove(double element)
Removes the first occurrence of the specified element.
|
double |
remove(int index)
Removes the element at the specified position and shifts any subsequent
elements to the left (subtracts one from their indices).
|
boolean |
removeAll(double[] a)
Removes from this DoubleArrayList all of its elements that are contained
in the specified array.
|
boolean |
removeAll(DoubleArrayList v)
Removes from this DoubleArrayList all of its elements that are contained
in the specified DoubleArrayList.
|
void |
removeAllElements()
Removes all components from this DoubleArrayList.
|
boolean |
removeAllFirst(double[] a)
Removes from this DoubleArrayList the first occurrence of the elements
that are contained in the specified array
|
boolean |
removeAllFirst(DoubleArrayList v)
Removes from this DoubleArrayList the first occurrence of the elements
that are contained in the specified DoubleArrayList.
|
boolean |
removeElement(double element)
Removes the first occurrence of the specified element.
|
void |
removeElementAt(int index)
Deletes the component at the specified index.
|
void |
removeRange(int fromIndex,
int toIndex)
Removes from this DoubleArrayList all of the elements whose index is
between fromIndex, inclusive and toIndex, exclusive.
|
boolean |
retainAll(DoubleArrayList v)
Retains only the elements in this DoubleArrayList whose elements are
contained in the specified DoubleArrayList.
|
double |
set(int index,
double element)
Replaces the element at the specified position in this DoubleArrayList with
the specified element.
|
void |
setElementAt(double element,
int index)
Sets the component at the specified index of this DoubleArrayList to be the
specified double.
|
void |
setIncrementFactor(float incrementFactor) |
void |
setLast(double element)
Replaces the element at the last position in this DoubleArrayList with
the specified element.
|
void |
setSize(int newSize)
Sets the size of this DoubleArrayList.
|
int |
size()
Returns the number of components in this DoubleArrayList.
|
double[] |
toArray()
Returns an array containing all of the elements in this DoubleArrayList in
the correct order.
|
java.lang.String |
toString()
Returns a string representation of this DoubleArrayList
|
void |
trimToSize()
Trims the capacity of this DoubleArrayList to be the DoubleArrayList's current
size.
|
public DoubleArrayList(int initialCapacity,
int capacityIncrement)
initialCapacity - the initial capacity of the DoubleArrayList.capacityIncrement - amount by which the capacity is increased on overflow.java.lang.NegativeArraySizeException - if the specified initial capacity is negative.public DoubleArrayList(int initialCapacity)
initialCapacity - the initial capacity of the DoubleArrayList.java.lang.NegativeArraySizeException - if the specified initial capacity is negative.public DoubleArrayList()
public DoubleArrayList(double[] a)
a - an array of doubles.public DoubleArrayList(java.util.Collection c)
c - the collection whose elements are to be placed into this DoubleArrayList.java.lang.ClassCastException - if the collection contains a non-number.public final void copyInto(double[] a)
a - the array into which the components get copied.java.lang.IndexOutOfBoundsException - if the array is too small.public final void trimToSize()
public final void ensureCapacity(int minCapacity)
If the current capacity of this DoubleArrayList is less than minCapacity, then its capacity is increased by replacing its internal data array, kept in the field elementData, with a larger one. The size of the new data array will be the old size plus capacityIncrement, unless the value of capacityIncrement is less than or equal to zero, in which case the new capacity will be the old capacity multiplied by incrementFactor; but if this new size is still smaller than minCapacity, then the new capacity will be minCapacity.
minCapacity - the desired minimum capacity.public final void setSize(int newSize)
newSize - the new size of this DoubleArrayList.public final int capacity()
public final int size()
public final boolean isEmpty()
public final boolean contains(double element)
element - a double.public final int indexOf(double element)
element - a double.public final int indexOf(double element,
int index)
element - a double.index - the non-negative index to start searching from.java.lang.IndexOutOfBoundsException - if index is negative.public final int lastIndexOf(double element)
element - the desired component.public final int lastIndexOf(double element,
int index)
element - a double.index - the non-negative index to start searching from.java.lang.IndexOutOfBoundsException - if index is invalid.public final double elementAt(int index)
index - an index into this DoubleArrayList.java.lang.ArrayIndexOutOfBoundsException - if the index is invalid.public final double firstElement()
java.lang.ArrayIndexOutOfBoundsException - if this DoubleArrayList is empty.public final double lastElement()
java.lang.ArrayIndexOutOfBoundsException - if this DoubleArrayList is empty.public final void setElementAt(double element,
int index)
The index must be a value greater than or equal to 0 and less than the current size of the DoubleArrayList.
This method is identical in functionality to the set method except that the latter returns the old value that was stored at the specified position and it has its argument in a different order.
element - what the component is to be set to.index - the specified index.java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.public final void removeElementAt(int index)
The index must be a value greater than or equal to 0 and less than the current size of the DoubleArrayList.
This method is identical in functionality to the remove(int) method except that the remove(int) method returns the old value that was stored at the specified position.
index - the index of the double to remove.java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.public final void insertElementAt(double element,
int index)
The index must be a value greater than or equal to 0 and less than or equal to the current size of the DoubleArrayList. (If the index is equal to the current size of the DoubleArrayList, the new element is appended to the DoubleArrayList.)
This method is identical in functionality to the add(int, double) method except that the latter method reverses the order of the arguments, to match array usage more closely.
element - the element to insert.index - where to insert the new component.java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.public final void addElement(double element)
This method is identical in functionality to the add(double) method except that the latter returns a boolean.
element - the component to be added.public final void removeAllElements()
public final java.lang.Object clone()
clone in class java.lang.Objectpublic final double[] toArray()
public final double get(int index)
java.lang.ArrayIndexOutOfBoundsException - if the index is invalid.public final double set(int index,
double element)
index - index of element to replace.element - element to be stored at the specified position.java.lang.ArrayIndexOutOfBoundsException - if index is out of range.public final void setLast(double element)
element - element to be stored at the last position.java.lang.ArrayIndexOutOfBoundsException - if index is out of range.public final boolean add(double element)
element - element to be appended to this DoubleArrayList.public final boolean remove(double element)
N.B.Because remove(double) is ambiguous, it is not supported for DoubleArrayLists; its functionality is provided by removeIndex(int) and removeElement(double).
element - element to be removed from this DoubleArrayList, if present.public final boolean removeElement(double element)
element - element to be removed from this DoubleArrayList, if present.public final void add(int index,
double element)
index - index at which the specified element is to be inserted.element - element to be inserted.java.lang.ArrayIndexOutOfBoundsException - if index is out of range.public final double remove(int index)
index - the index of the element to removed.java.lang.ArrayIndexOutOfBoundsException - if index is out of range.public final void clear()
public final boolean containsAll(double[] a)
a - array containing the elements to be tested for membership.public final boolean containsAll(DoubleArrayList v)
v - DoubleArrayList of elements to be tested for membership.public final boolean addAll(double[] a)
a - array containing the elements to be inserted.java.lang.ClassCastException - if the collection contains a non-number.public final boolean addAll(DoubleArrayList v)
v - the DoubleArrayList of elements to be added.public final boolean removeAll(double[] a)
a - array of elements to be removed.public final boolean removeAll(DoubleArrayList v)
v - the DoubleArrayList of elements to be removed.public final boolean removeAllFirst(double[] a)
a - array of elements to be removed.public final boolean removeAllFirst(DoubleArrayList v)
v - the DoubleArrayList of elements to be removed.public final boolean retainAll(DoubleArrayList v)
v - DoubleArrayList of elements to be retained.public final void addAll(int index,
double[] a)
index - index at which the specified element is to be inserted.a - array of elements to be inserted.java.lang.ArrayIndexOutOfBoundsException - if index is out of range.public final void addAll(int index,
DoubleArrayList v)
index - index where to insert the first elementv - DoubleArrayList to be inserted into this DoubleArrayList.java.lang.ArrayIndexOutOfBoundsException - if index is invalid.public final boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to be compared for equality with this DoubleArrayList.public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic void removeRange(int fromIndex,
int toIndex)
N.B. Note that this method is public, whereas - strangely enough, it is protected in the java.util.ArrayList API!
fromIndex - index of first element to be removed.toIndex - index after last element to be removed.public final void setIncrementFactor(float incrementFactor)
incrementFactor - a float that is between 1.1 and 5.0java.lang.IllegalArgumentException - if not between 1.1 and 5.0public final void clear(int index)
index - the index above which clearing takes effect