Class ArrayBinList

  • All Implemented Interfaces:
    BinList

    public abstract class ArrayBinList
    extends java.lang.Object
    implements BinList
    Abstract subclass of BinList suitable for implementations based on arrays. The defining feature is that the the maximum bin count can be described as an int rather than a long.
    Since:
    5 Oct 2015
    Author:
    Mark Taylor
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface uk.ac.starlink.ttools.plot2.layer.BinList

        BinList.Result
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ArrayBinList​(int size, Combiner combiner)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void copyBin​(int index, Combiner.Container container)
      Copies bin content from a Container into the storage used by this implementation for a given bin.
      static BinList.Result createDoubleMaskResult​(java.util.BitSet mask, double[] values)
      Returns a Result implementation based on a bin occupation mask and an array of bin content values.
      static ArrayBinList fromHashBinList​(HashBinList in)
      Tries to create an ArrayBinList with the same content as a supplied HashBinList.
      protected abstract double getBinResultInt​(int index)
      Variant of the getValue method that takes a 32-bit index.
      Combiner getCombiner()
      Returns the combination method used for bins.
      BinList.Result getResult()
      Returns an object containing the result values accumulated into the bins so far.
      long getSize()
      Returns the maximum number of bins.
      void submitToBin​(long lndex, double datum)
      Adds a given numeric value to the bin at the given index.
      protected abstract void submitToBinInt​(int index, double value)
      Variant of the addToBin method that takes a 32-bit index.
      • Methods inherited from class java.lang.Object

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

      • ArrayBinList

        protected ArrayBinList​(int size,
                               Combiner combiner)
        Constructor.
        Parameters:
        size - bin count
        combiner - combiner
    • Method Detail

      • submitToBinInt

        protected abstract void submitToBinInt​(int index,
                                               double value)
        Variant of the addToBin method that takes a 32-bit index.
        Parameters:
        index - bin index
        value - increment for the current bin value
      • getBinResultInt

        protected abstract double getBinResultInt​(int index)
        Variant of the getValue method that takes a 32-bit index.
        Parameters:
        index - bin index
        Returns:
        bin value
      • copyBin

        protected abstract void copyBin​(int index,
                                        Combiner.Container container)
        Copies bin content from a Container into the storage used by this implementation for a given bin. The container must be one appropriate to this bin list's Combiner.
        Parameters:
        index - bin index
        container - combiner's container containing bin state
      • submitToBin

        public void submitToBin​(long lndex,
                                double datum)
        Description copied from interface: BinList
        Adds a given numeric value to the bin at the given index. In general, NaN values should not be submitted.
        Specified by:
        submitToBin in interface BinList
        Parameters:
        lndex - bin index
        datum - finite value to submit to the bin
      • getSize

        public long getSize()
        Description copied from interface: BinList
        Returns the maximum number of bins. All bins have an index in the range 0..size-1.
        Specified by:
        getSize in interface BinList
        Returns:
        bin count
      • getCombiner

        public Combiner getCombiner()
        Description copied from interface: BinList
        Returns the combination method used for bins.
        Specified by:
        getCombiner in interface BinList
        Returns:
        combiner
      • getResult

        public BinList.Result getResult()
        Description copied from interface: BinList
        Returns an object containing the result values accumulated into the bins so far.

        It is up to implementations to decide how to implement this method. In some cases the return value may be an adapter that extracts results as required from the data structure used for value accumulation, but in others it may return a new data structure which copies the accumulated values to a more compact form up front. Therefore this may or may not be an expensive method, and the return value may or may not be affected by subsequent BinList.submitToBin(long, double) calls.

        Specified by:
        getResult in interface BinList
        Returns:
        accumulated bin values
      • fromHashBinList

        public static ArrayBinList fromHashBinList​(HashBinList in)
        Tries to create an ArrayBinList with the same content as a supplied HashBinList. Null may be returned if it can't be done.
        Parameters:
        in - bin list whose data is to be copied
        Returns:
        array bin list with copied content, or null if unsuccessful
      • createDoubleMaskResult

        public static BinList.Result createDoubleMaskResult​(java.util.BitSet mask,
                                                            double[] values)
        Returns a Result implementation based on a bin occupation mask and an array of bin content values.
        Parameters:
        mask - bin occupation mask
        values - data values per bin