Class DogArray_F64

java.lang.Object
org.ddogleg.struct.DogArray_F64
All Implemented Interfaces:
DogArrayPrimitive<DogArray_F64>

public class DogArray_F64 extends Object implements DogArrayPrimitive<DogArray_F64>
Growable array composed of doubles.
  • Field Details

    • data

      public double[] data
    • size

      public int size
  • Constructor Details

    • DogArray_F64

      public DogArray_F64(int reserve)
    • DogArray_F64

      public DogArray_F64()
  • Method Details

    • zeros

      public static DogArray_F64 zeros(int length)
      Creates a queue with the specified length as its size filled with all zeros
    • array

      public static DogArray_F64 array(double... values)
    • range

      public static DogArray_F64 range(int idx0, int idx1)
      Returns a new array with values containing range of integer numbers from idx0 to idx1-1.
      Parameters:
      idx0 - Lower extent, inclusive.
      idx1 - Upper extent, exclusive.
      Returns:
      new array.
    • count

      public int count(double value)
      Counts the number of times the specified value occurs in the list
    • isEquals

      public boolean isEquals(double... values)
      Sees is the primitive array is equal to the values in this array
      Parameters:
      values - primitive array
      Returns:
      true if equal or false if not
    • isEquals

      public boolean isEquals(DogArray_F64 values)
    • reset

      public DogArray_F64 reset()
      Description copied from interface: DogArrayPrimitive
      Sets the size to zero.
      Specified by:
      reset in interface DogArrayPrimitive<DogArray_F64>
      Returns:
      Returns 'this' to allow chaining of operations.
    • addAll

      public void addAll(DogArray_F64 queue)
    • addAll

      public void addAll(double[] array, int startIndex, int endIndex)
    • add

      public void add(double val)
    • push

      public void push(double val)
    • setTo

      public DogArray_F64 setTo(double[] array, int offset, int length)
      Sets this array to be equal to the array segment
      Parameters:
      array - (Input) source array
      offset - first index
      length - number of elements to copy
    • setTo

      public DogArray_F64 setTo(double... src)
      Set's the value of this array to the passed in raw array.
      Parameters:
      src - (Input) The input array
      Returns:
      A reference to "this" to allow chaining of commands
    • toArray

      public double[] toArray()
      Creates a new primitive array which is a copy.
    • remove

      public void remove(int index)
    • remove

      public void remove(int first, int last)
      Removes elements from the list starting at 'first' and ending at 'last'
      Parameters:
      first - First index you wish to remove. Inclusive.
      last - Last index you wish to remove. Inclusive.
    • insert

      public void insert(int index, double value)
      Inserts the value at the specified index and shifts all the other values down.
    • removeSwap

      public double removeSwap(int index)
      Removes the specified index from the array by swapping it with last element. Does not preserve order but has a runtime of O(1).
      Parameters:
      index - The index to be removed.
      Returns:
      The removed object
    • removeTail

      public double removeTail()
    • get

      public double get(int index)
    • getTail

      public double getTail()
    • getTail

      public double getTail(int index)
      Returns an element starting from the end of the list. 0 = size -1
    • setTail

      public void setTail(int index, double value)
    • getFraction

      public double getFraction(double fraction)
      Gets the value at the index which corresponds to the specified fraction
      Parameters:
      fraction - 0 to 1 inclusive
      Returns:
      value at fraction
    • unsafe_get

      public double unsafe_get(int index)
    • set

      public void set(int index, double value)
    • setTo

      public DogArray_F64 setTo(DogArray_F64 original)
      Description copied from interface: DogArrayPrimitive
      Turns 'this' into a copy of 'original'
      Specified by:
      setTo in interface DogArrayPrimitive<DogArray_F64>
      Parameters:
      original - queue that is to be copied
      Returns:
      Returns 'this' to allow chaining of operations.
    • resize

      public DogArray_F64 resize(int size)
      Description copied from interface: DogArrayPrimitive

      Ensures that the internal array is at least this size. Value of elements previously in the array will not be changed. If the size is increased then the value of new elements in undefined.

      If you wish to resize the array and avoid copying over past values for performance reasons, then you must either resize(0) or call DogArrayPrimitive.reset() first.
      Specified by:
      resize in interface DogArrayPrimitive<DogArray_F64>
      Parameters:
      size - desired new size
    • resize

      public DogArray_F64 resize(int size, double value)
      Resizes the array and assigns the default value to every new element.
      Parameters:
      size - New size
      value - Default value
    • resetResize

      @Deprecated public void resetResize(int size, double value)
      Deprecated.
      Convenience function that will first call reset() then resize(int, double), ensuring that every element in the array will have the specified value
      Parameters:
      size - New size
      value - New value of every element
    • resize

      public DogArray_F64 resize(int size, DogLambdas.AssignIdx_F64 op)
      Resizes and assigns the new elements (if any) to the value specified by the lambda
      Parameters:
      size - New sie
      op - Assigns default values
    • fill

      public void fill(double value)
    • fill

      public void fill(int idx0, int idx1, double value)
    • contains

      public boolean contains(double value)
    • extend

      public void extend(int size)
      Description copied from interface: DogArrayPrimitive
      Changes the array to the specified size. If there is not enough storage, a new internal array is created and the elements copied over. This is the same as: a.reserve(size);a.size = size;
      Specified by:
      extend in interface DogArrayPrimitive<DogArray_F64>
      Parameters:
      size - desired new size
    • reserve

      public void reserve(int amount)
      Description copied from interface: DogArrayPrimitive
      Ensures that the internal array's length is at least this size. Size is left unchanged. If the array is not empty and it needs to grow then the existing array is copied into the new array.
      Specified by:
      reserve in interface DogArrayPrimitive<DogArray_F64>
      Parameters:
      amount - minimum size of internal array
    • size

      public int size()
      Description copied from interface: DogArrayPrimitive
      Number of elements in the queue
      Specified by:
      size in interface DogArrayPrimitive<DogArray_F64>
      Returns:
      size of queue
    • zero

      public void zero()
      Description copied from interface: DogArrayPrimitive
      Sets all elements to 0 or False for binary queues
      Specified by:
      zero in interface DogArrayPrimitive<DogArray_F64>
    • copy

      public DogArray_F64 copy()
      Specified by:
      copy in interface DogArrayPrimitive<DogArray_F64>
    • flip

      public void flip()
      Description copied from interface: DogArrayPrimitive
      Flips the elements such that a[i] = a[N-i-1] where N is the number of elements.
      Specified by:
      flip in interface DogArrayPrimitive<DogArray_F64>
    • pop

      public double pop()
    • indexOf

      public int indexOf(double value)
      Returns the index of the first element with the specified 'value'. return -1 if it wasn't found
      Parameters:
      value - Value to search for
      Returns:
      index or -1 if it's not in the list
    • indexOfGreatest

      public int indexOfGreatest()
    • indexOfLeast

      public int indexOfLeast()
    • sort

      public void sort()
      Description copied from interface: DogArrayPrimitive
      Sorts the data from smallest to largest
      Specified by:
      sort in interface DogArrayPrimitive<DogArray_F64>
    • sort

      public void sort(QuickSort_F64 sorter)
      Sort but with a re-usable sorter to avoid declaring new memory
    • shuffle

      public void shuffle(Random rand)
      Shuffle elements by randomly swapping them
    • forIdx

      public void forIdx(DogArray_F64.FunctionEachIdx func)
    • forEach

      public void forEach(DogArray_F64.FunctionEach func)
    • applyIdx

      public void applyIdx(DogArray_F64.FunctionApplyIdx func)
    • count

      public int count(DogArray_F64.Filter filter)