DoubleArrayList (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.language.util

## Class DoubleArrayList

- java.lang.Object
- - hlt.language.util.DoubleArrayList

- Direct Known Subclasses:
    DoubleStack

      public class DoubleArrayList
      extends java.lang.Object

  This class implements a vector of primitive `double` elements to alleviate the need to use an ArrayList of `Double` wrappers. It implements all public members items of the `java.util.ArrayList` API that make sense when dealing with primitive `double` elements rather than `Object`s.

  Like `java.util.ArrayList`, its underlying representation can grow dynamically. As well, it is not synchronized.

  Version:
    Last modified on Thu Nov 22 04:56:16 2012 by hak
  Author:
    Hassan Aït-Kaci
  Copyright:
    © Hassan Aït-Kaci

- - ### Constructor Summary

    Constructors
    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.

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DoubleArrayList

          public DoubleArrayList(int initialCapacity,
                         int capacityIncrement)

      Constructs an empty DoubleArrayList with the specified initial capacity and capacity increment.
      Parameters:
        `initialCapacity` - the initial capacity of the DoubleArrayList.
        `capacityIncrement` - amount by which the capacity is increased on overflow.
      Throws:
        `java.lang.NegativeArraySizeException` - if the specified initial capacity is negative.

    - #### DoubleArrayList

          public DoubleArrayList(int initialCapacity)

      Constructs an empty DoubleArrayList with the specified initial capacity and with its capacity increment equal to zero.
      Parameters:
        `initialCapacity` - the initial capacity of the DoubleArrayList.
      Throws:
        `java.lang.NegativeArraySizeException` - if the specified initial capacity is negative.

    - #### DoubleArrayList

          public DoubleArrayList()

      Constructs an empty DoubleArrayList so that its internal data array has size 10 and its standard capacity increment is zero.

    - #### DoubleArrayList

          public DoubleArrayList(double[] a)

      Constructs a doubleArrayList containing the values contained in the specified array, in the same order.
      Parameters:
        `a` - an array of doubles.

    - #### DoubleArrayList

          public 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. If any object in the collection is not an instance of java.lang.Number, a ClassCastException exception is thrown.
      Parameters:
        `c` - the collection whose elements are to be placed into this DoubleArrayList.
      Throws:
        `java.lang.ClassCastException` - if the collection contains a non-number.

  - ### Method Detail

    - #### copyInto

          public final void copyInto(double[] a)

      Copies the components of this DoubleArrayList into the specified array. The item at index k in this DoubleArrayList is copied into component k of a. The array must be big enough to hold all the elements of this DoubleArrayList, else an IndexOutOfBoundsException is thrown.
      Parameters:
        `a` - the array into which the components get copied.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the array is too small.

    - #### trimToSize

          public final void trimToSize()

      Trims the capacity of this DoubleArrayList to be the DoubleArrayList's current size. If the capacity of this DoubleArrayList is larger than its current size, then the capacity is changed to equal the size by replacing its internal data array, kept in the field elementData, with a smaller one. An application can use this operation to minimize the storage of a DoubleArrayList.

    - #### ensureCapacity

          public final 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.

      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.

      Parameters:
        `minCapacity` - the desired minimum capacity.

    - #### setSize

          public final void setSize(int newSize)

      Sets the size of this DoubleArrayList. If the new size is greater than the current size, new zeroes are added to the end of the DoubleArrayList.
      Parameters:
        `newSize` - the new size of this DoubleArrayList.

    - #### capacity

          public final int capacity()

      Returns the current capacity of this DoubleArrayList.
      Returns:
        the current capacity the length of its internal data array.

    - #### size

          public final int size()

      Returns the number of components in this DoubleArrayList.
      Returns:
        the number of components in this DoubleArrayList.

    - #### isEmpty

          public final boolean isEmpty()

      Tests if this DoubleArrayList has no components.
      Returns:
        true if this DoubleArrayList's size is zero; false otherwise.

    - #### contains

          public final boolean contains(double element)

      Tests if the specified double is a component in this DoubleArrayList.
      Parameters:
        `element` - a double.
      Returns:
        true if the specified double is in this DoubleArrayList; false otherwise.

    - #### indexOf

          public final int indexOf(double element)

      Searches for the first occurrence of the given double; returns -1 if it is not found.
      Parameters:
        `element` - a double.
      Returns:
        the index of the first occurrence of the argument or -1.

    - #### indexOf

          public final 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.
      Parameters:
        `element` - a double.
        `index` - the non-negative index to start searching from.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if index is negative.

    - #### lastIndexOf

          public final 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.
      Parameters:
        `element` - the desired component.
      Returns:
        the index of the last occurrence of the specified double, or -1.

    - #### lastIndexOf

          public final 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.
      Parameters:
        `element` - a double.
        `index` - the non-negative index to start searching from.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if index is invalid.

    - #### elementAt

          public final double elementAt(int index)

      Returns the component at the specified index. This method is identical in functionality to the get method.
      Parameters:
        `index` - an index into this DoubleArrayList.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if the index is invalid.

    - #### firstElement

          public final double firstElement()

      Returns the first component (the item at index 0) of this DoubleArrayList.
      Returns:
        the first component of this DoubleArrayList.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if this DoubleArrayList is empty.

    - #### lastElement

          public final double lastElement()

      Returns the last component of the DoubleArrayList.
      Returns:
        the last component of the DoubleArrayList, i.e., the component at size() - 1.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if this DoubleArrayList is empty.

    - #### setElementAt

          public final void setElementAt(double element,
                          int index)

      Sets the component at the specified index of this DoubleArrayList to be the specified double. The previous component at that position is lost.

      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.

      Parameters:
        `element` - what the component is to be set to.
        `index` - the specified index.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if the index was invalid.

    - #### removeElementAt

          public final void removeElementAt(int index)

      Deletes the component at the specified index. Each component in this DoubleArrayList with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously. The size of this DoubleArrayList is decreased by 1.

      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.

      Parameters:
        `index` - the index of the double to remove.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if the index was invalid.

    - #### insertElementAt

          public final void insertElementAt(double element,
                             int index)

      Inserts the specified double as a component in this DoubleArrayList at the specified index. Each component in this DoubleArrayList with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

      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.

      Parameters:
        `element` - the element to insert.
        `index` - where to insert the new component.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if the index was invalid.

    - #### addElement

          public final void addElement(double element)

      Adds the specified component to the end of this DoubleArrayList, increasing its size by one. The capacity of this DoubleArrayList is increased if its size becomes greater than its capacity.

      This method is identical in functionality to the add(double) method except that the latter returns a boolean.

      Parameters:
        `element` - the component to be added.

    - #### removeAllElements

          public final void removeAllElements()

      Removes all components from this DoubleArrayList. This method is identical in functionality to the clear method.

    - #### clone

          public final java.lang.Object clone()

      Returns a clone of this DoubleArrayList. The copy will contain a reference to a clone of the internal data array, not a reference to the original internal data array of this DoubleArrayList object.
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        a clone of this DoubleArrayList.

    - #### toArray

          public final double[] toArray()

      Returns an array containing all of the elements in this DoubleArrayList in the correct order.

    - #### get

          public final double get(int index)

      Returns the element at the specified position in this DoubleArrayList.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if the index is invalid.

    - #### set

          public final double set(int index,
                   double element)

      Replaces the element at the specified position in this DoubleArrayList with the specified element.
      Parameters:
        `index` - index of element to replace.
        `element` - element to be stored at the specified position.
      Returns:
        the element previously at the specified position.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if index is out of range.

    - #### setLast

          public final void setLast(double element)

      Replaces the element at the last position in this DoubleArrayList with the specified element.
      Parameters:
        `element` - element to be stored at the last position.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if index is out of range.

    - #### add

          public final boolean add(double element)

      Appends the specified element to the end of this DoubleArrayList.
      Parameters:
        `element` - element to be appended to this DoubleArrayList.
      Returns:
        true (following the `java.util.ArrayList` API).

    - #### remove

          public final boolean remove(double element)

      Removes the first occurrence of the specified element. If this DoubleArrayList does not contain the element, it is left unchanged.

      N.B.Because `remove(double)` is ambiguous, it is not supported for DoubleArrayLists; its functionality is provided by `removeIndex(int)` and `removeElement(double)`.

      Parameters:
        `element` - element to be removed from this DoubleArrayList, if present.
      Returns:
        true if this DoubleArrayList contained the specified element.

    - #### removeElement

          public final boolean removeElement(double element)

      Removes the first occurrence of the specified element. If this DoubleArrayList does not contain the element, it is left unchanged. Note that this method is identical to remove(double).
      Parameters:
        `element` - element to be removed from this DoubleArrayList, if present.
      Returns:
        true if this DoubleArrayList contained the specified element.

    - #### add

          public final void add(int index,
                 double element)

      Inserts the specified element at the specified position in this DoubleArrayList. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
      Parameters:
        `index` - index at which the specified element is to be inserted.
        `element` - element to be inserted.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if index is out of range.

    - #### remove

          public final double remove(int index)

      Removes the element at the specified position and shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed.
      Parameters:
        `index` - the index of the element to removed.
      Returns:
        the element that was at this index position.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if index is out of range.

    - #### clear

          public final void clear()

      Removes all of the elements from this DoubleArrayList.

    - #### containsAll

          public final boolean containsAll(double[] a)

      Returns true if this DoubleArrayList contains all of the elements in the specified array.
      Parameters:
        `a` - array containing the elements to be tested for membership.
      Returns:
        true if all of the elements of the specified array belong in this.

    - #### containsAll

          public final boolean containsAll(DoubleArrayList v)

      Returns true if this DoubleArrayList contains all of the elements in the specified DoubleArrayList.
      Parameters:
        `v` - DoubleArrayList of elements to be tested for membership.
      Returns:
        true if all of the elements of the specified collection belong in this.

    - #### addAll

          public final 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.
      Parameters:
        `a` - array containing the elements to be inserted.
      Returns:
        true (following the `java.util.ArrayList` API).
      Throws:
        `java.lang.ClassCastException` - if the collection contains a non-number.

    - #### addAll

          public final boolean addAll(DoubleArrayList v)

      Appends all of the elements in the specified DoubleArrayList to the end of this DoubleArrayList.
      Parameters:
        `v` - the DoubleArrayList of elements to be added.
      Returns:
        true (following the `java.util.ArrayList` API).

    - #### removeAll

          public final boolean removeAll(double[] a)

      Removes from this DoubleArrayList all of its elements that are contained in the specified array. Note that all occurrences of such elemeents are removed - not just the first.
      Parameters:
        `a` - array of elements to be removed.
      Returns:
        true if this DoubleArrayList changed as a result of the call.

    - #### removeAll

          public final boolean removeAll(DoubleArrayList v)

      Removes from this DoubleArrayList all of its elements that are contained in the specified DoubleArrayList. Note that all occurrences of such elemeents are removed - not just the first.
      Parameters:
        `v` - the DoubleArrayList of elements to be removed.
      Returns:
        true if this DoubleArrayList changed as a result of the call.

    - #### removeAllFirst

          public final boolean removeAllFirst(double[] a)

      Removes from this DoubleArrayList the first occurrence of the elements that are contained in the specified array
      Parameters:
        `a` - array of elements to be removed.
      Returns:
        true if this DoubleArrayList changed as a result of the call.

    - #### removeAllFirst

          public final boolean removeAllFirst(DoubleArrayList v)

      Removes from this DoubleArrayList the first occurrence of the elements that are contained in the specified DoubleArrayList.
      Parameters:
        `v` - the DoubleArrayList of elements to be removed.
      Returns:
        true if this DoubleArrayList changed as a result of the call.

    - #### retainAll

          public final boolean retainAll(DoubleArrayList v)

      Retains only the elements in this DoubleArrayList whose elements are contained in the specified DoubleArrayList. In other words, removes from this DoubleArrayList all of its elements that are not contained in the specified DoubleArrayList.
      Parameters:
        `v` - DoubleArrayList of elements to be retained.
      Returns:
        true if this DoubleArrayList changed as a result of the call.

    - #### addAll

          public final void addAll(int index,
                    double[] a)

      Inserts all the elements in the specified array at the specified position in this DoubleArrayList. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds the length of the array to their indices).
      Parameters:
        `index` - index at which the specified element is to be inserted.
        `a` - array of elements to be inserted.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if index is out of range.

    - #### addAll

          public final void addAll(int index,
                    DoubleArrayList v)

      Inserts all of the elements in the specified DoubleArrayList into this DoubleArrayList at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this DoubleArrayList in their order in the specified DoubleArrayList.
      Parameters:
        `index` - index where to insert the first element
        `v` - DoubleArrayList to be inserted into this DoubleArrayList.
      Throws:
        `java.lang.ArrayIndexOutOfBoundsException` - if index is invalid.

    - #### equals

          public final boolean equals(java.lang.Object o)

      Compares the specified object with this DoubleArrayList for equality. Returns true if and only if the specified object is also an DoubleArrayList, both have the same size, and all corresponding pairs of elements are equal. In other words, two DoubleArrayLists are defined to be equal if they contain the same elements in the same order.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `o` - the object to be compared for equality with this DoubleArrayList.
      Returns:
        true if the specified object is equal to this DoubleArrayList

    - #### hashCode

          public int hashCode()

      Returns the hash code value for this DoubleArrayList.
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this DoubleArrayList
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of this collection.

    - #### removeRange

          public void removeRange(int fromIndex,
                         int toIndex)

      Removes from this DoubleArrayList all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the ArrayList by (toIndex - fromIndex) elements. (If toIndex <= fromIndex, this operation has no effect.)

      N.B. Note that this method is public, whereas - strangely enough, it is protected in the `java.util.ArrayList` API!

      Parameters:
        `fromIndex` - index of first element to be removed.
        `toIndex` - index after last element to be removed.

    - #### setIncrementFactor

          public final void setIncrementFactor(float incrementFactor)

      Parameters:
        `incrementFactor` - a float that is between 1.1 and 5.0
      Throws:
        `java.lang.IllegalArgumentException` - if not between 1.1 and 5.0

    - #### clear

          public final void clear(int index)

      Clears all elements of this DoubleArraylist at index equal to or greater than the specified index. If this index value is out range, this clears all the DoubleArraylist.
      Parameters:
        `index` - the index above which clearing takes effect