Class HashBinList

  • All Implemented Interfaces:
    BinList

    public class HashBinList
    extends java.lang.Object
    implements BinList
    BinList implementation based on a hash. Good for sparse bin lists.
    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 
      Constructor Description
      HashBinList​(long size, Combiner combiner)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static BinList.Result createHashResult​(java.util.Map<java.lang.Long,​java.lang.Double> map)
      Returns a new Result instance based on a Map.
      Combiner getCombiner()
      Returns the combination method used for bins.
      java.util.Map<java.lang.Long,​Combiner.Container> getMap()
      Returns the hash used to store this bin list's state.
      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 index, double value)
      Adds a given numeric value to the bin at the given index.
      • Methods inherited from class java.lang.Object

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

      • HashBinList

        public HashBinList​(long size,
                           Combiner combiner)
        Constructor.
        Parameters:
        size - number of bins
        combiner - combiner
    • Method Detail

      • 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
      • submitToBin

        public void submitToBin​(long index,
                                double value)
        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:
        index - bin index
        value - finite value to submit to the bin
      • 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
      • getMap

        public java.util.Map<java.lang.Long,​Combiner.Container> getMap()
        Returns the hash used to store this bin list's state.
        Returns:
        index->container map
      • createHashResult

        public static BinList.Result createHashResult​(java.util.Map<java.lang.Long,​java.lang.Double> map)
        Returns a new Result instance based on a Map.
        Parameters:
        map - map of values
        Returns:
        result based on map