uk.ac.starlink.ttools.plot2.layer
Class Binner

java.lang.Object
  extended by uk.ac.starlink.ttools.plot2.layer.Binner

public class Binner
extends Object

Accumulates counts in an array of bins.

The array type starts at bytes and is dynamically adjusted to contain counts up to int size to save on memory. Is this overengineered?

Since:
15 Feb 2013
Author:
Mark Taylor

Constructor Summary
Binner(int n)
          Constructor.
 
Method Summary
 int getCount(int index)
          Returns the count in a given bin.
 int getLength()
          Returns the number of bins.
 long getTotal()
          Returns the total number of increments made to this binner.
 void increment(int index)
          Increments the count in a given bin by 1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Binner

public Binner(int n)
Constructor.

Parameters:
n - number of bins
Method Detail

getLength

public int getLength()
Returns the number of bins.

Returns:
bin count

increment

public void increment(int index)
Increments the count in a given bin by 1.

Parameters:
index - bin index

getCount

public int getCount(int index)
Returns the count in a given bin.

Parameters:
index - bin index

getTotal

public long getTotal()
Returns the total number of increments made to this binner.

Returns:
sum of all bins


Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.