Documentation of 'Catalano.Math.SparseArray' Java class
SparseArray
Catalano.Math

Class SparseArray

  • All Implemented Interfaces:
    java.lang.Iterable<SparseArray.Entry>


    public class SparseArray
    extends java.lang.Object
    implements java.lang.Iterable<SparseArray.Entry>
    Sparse array of double values.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      class  SparseArray.Entry
      The entry in a sparse array of double values.
    • Constructor Summary

      Constructors 
      Constructor and Description
      SparseArray()
      Initializes a new instance of the SparseArray class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void append(int i, double x)
      Append an entry to the array, optimizing for the case where the index is greater than all existing indices in the array.
      double get(int i)
      Returns the value of i-th entry.
      boolean isEmpty()
      Returns true if the array is empty.
      java.util.Iterator<SparseArray.Entry> iterator()
      Returns an iterator of nonzero entries.
      void remove(int i)
      Removes an entry.
      boolean set(int i, double x)
      Sets or add an entry.
      int size()
      Returns the number of nonzero entries.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • SparseArray

        public SparseArray()
        Initializes a new instance of the SparseArray class.
    • Method Detail

      • size

        public int size()
        Returns the number of nonzero entries.
        Returns:
        the number of nonzero entries
      • isEmpty

        public boolean isEmpty()
        Returns true if the array is empty.
        Returns:
        true if the array is empty.
      • iterator

        public java.util.Iterator<SparseArray.Entry> iterator()
        Returns an iterator of nonzero entries.
        Specified by:
        iterator in interface java.lang.Iterable<SparseArray.Entry>
        Returns:
        an iterator of nonzero entries
      • get

        public double get(int i)
        Returns the value of i-th entry.
        Parameters:
        i - the index of entry.
        Returns:
        the value of entry, 0.0 if the index doesn't exist in the array.
      • set

        public boolean set(int i,
                           double x)
        Sets or add an entry.
        Parameters:
        i - the index of entry.
        x - the value of entry.
        Returns:
        true if a new entry added, false if an existing entry updated.
      • append

        public void append(int i,
                           double x)
        Append an entry to the array, optimizing for the case where the index is greater than all existing indices in the array.
        Parameters:
        i - the index of entry.
        x - the value of entry.
      • remove

        public void remove(int i)
        Removes an entry.
        Parameters:
        i - the index of entry.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.