Class HashBinList
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.HashBinList
- All Implemented Interfaces:
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
Accumulates all the data from another BinList into this one.static BinList.Result
createHashResult
(Map<Long, Double> map) Returns a new Result instance based on a Map.getBinContainer
(long index) Returns a container representing the current contents of a given bin.Returns the combination method used for bins.getMap()
Returns the hash used to store this bin list's state.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.
-
Constructor Details
-
HashBinList
Constructor.- Parameters:
size
- number of binscombiner
- combiner
-
-
Method Details
-
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. -
getCombiner
Description copied from interface:BinList
Returns the combination method used for bins.- Specified by:
getCombiner
in interfaceBinList
- 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 interfaceBinList
- Parameters:
index
- bin indexvalue
- finite value to submit to the bin
-
getBinContainer
Description copied from interface:BinList
Returns a container representing the current contents of a given bin. This is only intended for reading; the effect of submitting additional data to the returned container is not defined.This method is here to support conversion between different BinList implementations.
- Specified by:
getBinContainer
in interfaceBinList
- Parameters:
index
- bin index- Returns:
- container instance reporting the current state of the bin; may be null if the bin is not populated
-
addBins
Accumulates all the data from another BinList into this one. The effect is the same as if all the data submitted toother
had been submitted to this.The other list must be of the same type (have the same combiner) as this one.
- Parameters:
other
- second BinList compatible with this one- Throws:
ClassCastException
- ifother
's type does not match this one
-
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. -
getMap
Returns the hash used to store this bin list's state.- Returns:
- index->container map
-
createHashResult
Returns a new Result instance based on a Map.- Parameters:
map
- map of values- Returns:
- result based on
map
-