public class Binner extends Object
An earlier implementation started off with a byte[]
array
and dynamically adjusted the storage as the maximum bin count increased
to a short[]
and then an int[]
array,
to save on memory.
The current implementation just uses an int[]
array,
on the untested assumption that
the extra cleverness is more trouble than it's worth;
the array size is not going to be of unlimited size
(expected use is to map a pixel grid, so it will usually be not much
more than a million).
Constructor and Description |
---|
Binner(int n)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Binner other)
Adds the contents of another binner to this one.
|
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.
|
public int getLength()
public void increment(int index)
index
- bin indexpublic int getCount(int index)
index
- bin indexpublic long getTotal()
public void add(Binner other)
other
- other binner, expected to be the same size as thisCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.