public class OnDemandHistogram3D extends java.lang.Object implements Histogram3D
Note: Rewrote from scratch for version 0.15.0 to use hash tables instead of int arrays. New version creates and throws away a lot of objects, which had been a problem with early JVMs but should be OK these days.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Hashtable |
hash |
private int |
maxValue1 |
private int |
maxValue2 |
private int |
maxValue3 |
private int |
numUniqueValues |
| Constructor and Description |
|---|
OnDemandHistogram3D(int max1,
int max2,
int max3)
Creates a new histogram, internally creates the hash table
for triplet values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Sets all counters to zero.
|
private Histogram3DNode |
createNode(int v1,
int v2,
int v3) |
int |
getEntry(int index1,
int index2,
int index3)
Returns the counter value of (index1, index2, index3).
|
int |
getMaxValue(int index)
Returns the maximum index value for one of the three indexes.
|
int |
getNumUsedEntries()
Returns the number of used entries (those entries with
a counter value larger than zero).
|
void |
increaseEntry(int index1,
int index2,
int index3)
Increases the counter value of (index1, index2, index3) by one.
|
void |
setEntry(int index1,
int index2,
int index3,
int newValue)
Sets the counter value of (index1, index2, index3) to newValue.
|
private java.util.Hashtable hash
private int numUniqueValues
private final int maxValue1
private final int maxValue2
private final int maxValue3
public OnDemandHistogram3D(int max1,
int max2,
int max3)
public void clear()
Histogram3Dclear in interface Histogram3Dprivate Histogram3DNode createNode(int v1, int v2, int v3)
public int getEntry(int index1,
int index2,
int index3)
Histogram3DgetEntry in interface Histogram3Dindex1 - first of the three values forming the threedimensional indexindex2 - second of the three values forming the threedimensional indexindex3 - three of the three values forming the threedimensional indexpublic int getMaxValue(int index)
throws java.lang.IllegalArgumentException
Histogram3DgetMaxValue in interface Histogram3Djava.lang.IllegalArgumentException - if the index formed by the arguments is invalidpublic int getNumUsedEntries()
Histogram3DgetNumUsedEntries in interface Histogram3Dpublic void increaseEntry(int index1,
int index2,
int index3)
Histogram3DsetEntry(index1, index2, index3, getEntry(index1, index2, index3) + 1);
However, implementations of this method may take advantage of
implementation details to provide a more efficient approach.increaseEntry in interface Histogram3Dindex1 - first of the three values forming the threedimensional indexindex2 - second of the three values forming the threedimensional indexindex3 - three of the three values forming the threedimensional indexpublic void setEntry(int index1,
int index2,
int index3,
int newValue)
Histogram3DsetEntry in interface Histogram3Dindex1 - first of the three values forming the threedimensional indexindex2 - second of the three values forming the threedimensional indexindex3 - three of the three values forming the threedimensional indexnewValue - the counter value that is assigned to the argument index