Class DoubleArrayList

java.lang.Object
math.DoubleArrayList

public class DoubleArrayList extends Object
this class creates a dynamic list of double. it is useful to use when you want to access the elements randomly, but you have often to cancel the first part of list or to add elements in the end but in general the size is approximately constant.
Author:
Federico Granata
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of DoubleArrayList
    DoubleArrayList(double[] data)
    Creates a new instance of DoubleArrayList initialized
    DoubleArrayList(int minCapacity)
    Creates a new instance of DoubleArrayList with a minimum capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(double newD)
    add a new element at the end of the list
    void
    It clears all the data inside the List.
    void
    delFirst(int dim)
    deletes the first dim data.
    void
    ensureCapacity(int dim)
    Ensures the minimum capacity of the List.
    double
    get(int pos)
    Gets the data in position pos.
    int
    gets the size of the List
    void
    set(int pos, double newD)
    sets the element in position pos
    double[]
    toArray(int startPos, int endPos)
    creates an array of double that contains the data from startPos to endPos.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DoubleArrayList

      public DoubleArrayList()
      Creates a new instance of DoubleArrayList
    • DoubleArrayList

      public DoubleArrayList(int minCapacity)
      Creates a new instance of DoubleArrayList with a minimum capacity.
      Parameters:
      minCapacity - the minimum capcity of the neew list
    • DoubleArrayList

      public DoubleArrayList(double[] data)
      Creates a new instance of DoubleArrayList initialized
      Parameters:
      data - the array of initializing data
  • Method Details

    • add

      public boolean add(double newD)
      add a new element at the end of the list
      Parameters:
      newD - the new element
      Returns:
      true if the operation is successful, false otherwise
    • ensureCapacity

      public void ensureCapacity(int dim)
      Ensures the minimum capacity of the List. If the lists has more element then dim it throws an exception.
      Parameters:
      dim -
    • clear

      public void clear()
      It clears all the data inside the List.
    • get

      public double get(int pos)
      Gets the data in position pos.
      Parameters:
      pos -
      Returns:
      the data
    • delFirst

      public void delFirst(int dim)
      deletes the first dim data.
      Parameters:
      dim -
    • toArray

      public double[] toArray(int startPos, int endPos)
      creates an array of double that contains the data from startPos to endPos.
      Parameters:
      startPos -
      endPos -
      Returns:
    • set

      public void set(int pos, double newD)
      sets the element in position pos
      Parameters:
      pos -
      newD -
    • getSize

      public int getSize()
      gets the size of the List
      Returns: