Documentation of 'jsat.utils.DoubleList' Java class
DoubleList
jsat.utils

Class DoubleList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<java.lang.Double>, java.util.Collection<java.lang.Double>, java.util.List<java.lang.Double>, java.util.RandomAccess


    public class DoubleList
    extends java.util.AbstractList<java.lang.Double>
    implements java.io.Serializable, java.util.RandomAccess
    Provides a modifiable implementation of a List using a double array. This provides considerable memory efficency improvements over using an ArrayList to store doubles.
    Null is not allowed into the list.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      DoubleList()
      Creates a new empty DoubleList
      DoubleList(java.util.Collection<java.lang.Double> c)
      Creates a new DoubleList containing the values of the given collection
      DoubleList(int capacity)
      Creates a new empty DoubleList
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean add(double e)
      Performs exactly the same as add(java.lang.Double).
      boolean add(java.lang.Double e) 
      void add(int index, double element)
      Operates exactly as add(int, java.lang.Double)
      void add(int index, java.lang.Double element) 
      void clear() 
      java.lang.Double get(int index) 
      double[] getBackingArray()
      Returns the reference to the array that backs this list.
      double getD(int index)
      Operates exactly as get(int)
      Vec getVecView()
      Obtains a view of this double list as a dense vector with equal length.
      double peek()
      This method treats the underlying list as a stack.
      double pop()
      This method treats the underlying list as a stack.
      double push(double e)
      This method treats the underlying list as a stack.
      java.lang.Double remove(int index) 
      double removeD(int index)
      Operates exactly as remove(int)
      double set(int index, double element)
      Operates exactly as set(int, java.lang.Double)
      java.lang.Double set(int index, java.lang.Double element) 
      int size() 
      static java.util.List<java.lang.Double> unmodifiableView(double[] array, int length)
      Creates an returns an unmodifiable view of the given double array that requires only a small object allocation.
      static DoubleList view(double[] array, int length)
      Creates and returns a view of the given double array that requires only a small object allocation.
      • Methods inherited from class java.util.AbstractList

        addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.List

        addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Constructor Detail

      • DoubleList

        public DoubleList()
        Creates a new empty DoubleList
      • DoubleList

        public DoubleList(int capacity)
        Creates a new empty DoubleList
        Parameters:
        capacity - the starting internal capacity of the list
      • DoubleList

        public DoubleList(java.util.Collection<java.lang.Double> c)
        Creates a new DoubleList containing the values of the given collection
        Parameters:
        c - the collection of values to fill this double list with
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.lang.Double>
        Specified by:
        clear in interface java.util.List<java.lang.Double>
        Overrides:
        clear in class java.util.AbstractList<java.lang.Double>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.Double>
        Specified by:
        size in interface java.util.List<java.lang.Double>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.Double>
      • add

        public boolean add(double e)
        Performs exactly the same as add(java.lang.Double).
        Parameters:
        e - the value to add
        Returns:
        true if it was added, false otherwise
      • push

        public double push(double e)
        This method treats the underlying list as a stack. Pushes an item onto the top of this "stack".
        Parameters:
        e - the item to push onto the stack
        Returns:
        the value added to the stack
      • pop

        public double pop()
        This method treats the underlying list as a stack. Removes the item at the top of this "stack" and returns that item as the value.
        Returns:
        the item at the top of this stack (the last item pushed onto it)
      • peek

        public double peek()
        This method treats the underlying list as a stack. Gets the item at the top of this "stack" and returns that item as the value, but leaves it on the stack.
        Returns:
        the item at the top of this stack (the last item pushed onto it)
      • add

        public boolean add(java.lang.Double e)
        Specified by:
        add in interface java.util.Collection<java.lang.Double>
        Specified by:
        add in interface java.util.List<java.lang.Double>
        Overrides:
        add in class java.util.AbstractList<java.lang.Double>
      • getD

        public double getD(int index)
        Operates exactly as get(int)
        Parameters:
        index - the index of the value to get
        Returns:
        the value at the given index
      • get

        public java.lang.Double get(int index)
        Specified by:
        get in interface java.util.List<java.lang.Double>
        Specified by:
        get in class java.util.AbstractList<java.lang.Double>
      • set

        public double set(int index,
                          double element)
        Operates exactly as set(int, java.lang.Double)
        Parameters:
        index - the index to set
        element - the value to set
        Returns:
        the previous value at said index
      • set

        public java.lang.Double set(int index,
                                    java.lang.Double element)
        Specified by:
        set in interface java.util.List<java.lang.Double>
        Overrides:
        set in class java.util.AbstractList<java.lang.Double>
      • add

        public void add(int index,
                        double element)
        Operates exactly as add(int, java.lang.Double)
        Parameters:
        index - the index to add at
        element - the value to add
      • add

        public void add(int index,
                        java.lang.Double element)
        Specified by:
        add in interface java.util.List<java.lang.Double>
        Overrides:
        add in class java.util.AbstractList<java.lang.Double>
      • removeD

        public double removeD(int index)
        Operates exactly as remove(int)
        Parameters:
        index - the index to remove
        Returns:
        the value removed
      • remove

        public java.lang.Double remove(int index)
        Specified by:
        remove in interface java.util.List<java.lang.Double>
        Overrides:
        remove in class java.util.AbstractList<java.lang.Double>
      • getBackingArray

        public double[] getBackingArray()
        Returns the reference to the array that backs this list. Alterations to the array will be visible to the DoubelList and vise versa. The array returned may not the the same size as the value returned by size()
        Returns:
        the underlying array used by this DoubleList
      • getVecView

        public Vec getVecView()
        Obtains a view of this double list as a dense vector with equal length. This is a soft reference, and altering the values in the matrix with alter the double list, and vise versa.

        While no error will be thrown if the size of the underlying list changes, this view should be discarded if the size of the list changes. Once the list has changed sizes, there is no guarantee on the behavior that will occur if the vector is used.
        Returns:
        a vector view of this list
      • unmodifiableView

        public static java.util.List<java.lang.Double> unmodifiableView(double[] array,
                                                                        int length)
        Creates an returns an unmodifiable view of the given double array that requires only a small object allocation.
        Parameters:
        array - the array to wrap into an unmodifiable list
        length - the number of values of the array to use, starting from zero
        Returns:
        an unmodifiable list view of the array
      • view

        public static DoubleList view(double[] array,
                                      int length)
        Creates and returns a view of the given double array that requires only a small object allocation. Changes to the list will be reflected in the array up to a point. If the modification would require increasing the capacity of the array, a new array will be allocated - at which point operations will no longer be reflected in the original array.
        Parameters:
        array - the array to wrap by a DoubleList object
        length - the initial length of the list
        Returns:
        a DoubleList backed by the given array, unless modified to the point of requiring the allocation of a new array

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.