public class TwoDimensionalCounter<K1,K2> extends java.lang.Object implements TwoDimensionalCounterInterface<K1,K2>, java.io.Serializable
Constructor and Description |
---|
TwoDimensionalCounter() |
TwoDimensionalCounter(MapFactory<K1,ClassicCounter<K2>> outerFactory,
MapFactory<K2,MutableDouble> innerFactory) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(K1 key,
Counter<K2> c) |
void |
addAll(TwoDimensionalCounterInterface<K1,K2> c) |
void |
clean() |
void |
clear()
clears the map, total and default value
|
boolean |
containsFirstKey(K1 o1) |
boolean |
containsKey(K1 o1,
K2 o2) |
void |
decrementCount(K1 o1,
K2 o2) |
void |
decrementCount(K1 o1,
K2 o2,
double count) |
double |
defaultReturnValue() |
void |
defaultReturnValue(double rv) |
java.util.Set<java.util.Map.Entry<K1,ClassicCounter<K2>>> |
entrySet() |
boolean |
equals(java.lang.Object o) |
java.util.Set<K1> |
firstKeySet() |
ClassicCounter<Pair<K1,K2>> |
flatten() |
double |
getCount(K1 o1,
K2 o2) |
ClassicCounter<K2> |
getCounter(K1 o) |
MapFactory<K2,MutableDouble> |
getInnerMapFactory() |
MapFactory<K1,ClassicCounter<K2>> |
getOuterMapFactory() |
int |
hashCode() |
static <K1,K2> TwoDimensionalCounter<K1,K2> |
identityHashMapCounter() |
void |
incrementCount(K1 o1,
K2 o2) |
void |
incrementCount(K1 o1,
K2 o2,
double count) |
boolean |
isEmpty() |
static void |
main(java.lang.String[] args) |
void |
recomputeTotal() |
void |
remove(K1 key) |
double |
remove(K1 o1,
K2 o2) |
void |
removeZeroCounts() |
static <K1,K2> TwoDimensionalCounter<K2,K1> |
reverseIndexOrder(TwoDimensionalCounter<K1,K2> cc)
Produces a new ConditionalCounter.
|
java.util.Set<K2> |
secondKeySet() |
void |
setCount(K1 o1,
K2 o2,
double count) |
ClassicCounter<K2> |
setCounter(K1 o,
Counter<K2> c)
replace the counter for K1-index o by new counter c
|
int |
size() |
int |
sizeOuterMap() |
void |
subtractAll(K1 key,
Counter<K2> c) |
void |
subtractAll(TwoDimensionalCounterInterface<K1,K2> c,
boolean removeKeys) |
Counter<K1> |
sumInnerCounter()
Returns the counters with keys as the first key and count as the
total count of the inner counter for that key
|
java.lang.String |
toCSVString(java.text.NumberFormat nf) |
double[][] |
toMatrix(java.util.List<K1> firstKeys,
java.util.List<K2> secondKeys)
Given an ordering of the first (row) and second (column) keys, will produce
a double matrix.
|
java.lang.String |
toMatrixString(int cellSize) |
java.lang.String |
toMatrixString(int cellSize,
java.text.NumberFormat nf) |
java.lang.String |
toString()
A simple String representation of this TwoDimensionalCounter, which has the
String representation of each key pair on a separate line, followed by the
count for that pair.
|
double |
totalCount()
Takes linear time.
|
double |
totalCount(K1 k1) |
public TwoDimensionalCounter()
public TwoDimensionalCounter(MapFactory<K1,ClassicCounter<K2>> outerFactory, MapFactory<K2,MutableDouble> innerFactory)
public void defaultReturnValue(double rv)
defaultReturnValue
in interface TwoDimensionalCounterInterface<K1,K2>
public double defaultReturnValue()
defaultReturnValue
in interface TwoDimensionalCounterInterface<K1,K2>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public ClassicCounter<K2> getCounter(K1 o)
getCounter
in interface TwoDimensionalCounterInterface<K1,K2>
public java.util.Set<java.util.Map.Entry<K1,ClassicCounter<K2>>> entrySet()
public int size()
size
in interface TwoDimensionalCounterInterface<K1,K2>
public int sizeOuterMap()
public boolean containsKey(K1 o1, K2 o2)
containsKey
in interface TwoDimensionalCounterInterface<K1,K2>
public boolean containsFirstKey(K1 o1)
public void incrementCount(K1 o1, K2 o2)
incrementCount
in interface TwoDimensionalCounterInterface<K1,K2>
public void incrementCount(K1 o1, K2 o2, double count)
incrementCount
in interface TwoDimensionalCounterInterface<K1,K2>
public void decrementCount(K1 o1, K2 o2)
decrementCount
in interface TwoDimensionalCounterInterface<K1,K2>
public void decrementCount(K1 o1, K2 o2, double count)
decrementCount
in interface TwoDimensionalCounterInterface<K1,K2>
public void setCount(K1 o1, K2 o2, double count)
setCount
in interface TwoDimensionalCounterInterface<K1,K2>
public double remove(K1 o1, K2 o2)
remove
in interface TwoDimensionalCounterInterface<K1,K2>
public double getCount(K1 o1, K2 o2)
getCount
in interface TwoDimensionalCounterInterface<K1,K2>
public double totalCount()
totalCount
in interface TwoDimensionalCounterInterface<K1,K2>
public double totalCount(K1 k1)
totalCount
in interface TwoDimensionalCounterInterface<K1,K2>
public java.util.Set<K1> firstKeySet()
firstKeySet
in interface TwoDimensionalCounterInterface<K1,K2>
public ClassicCounter<K2> setCounter(K1 o, Counter<K2> c)
public static <K1,K2> TwoDimensionalCounter<K2,K1> reverseIndexOrder(TwoDimensionalCounter<K1,K2> cc)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toMatrixString(int cellSize)
toMatrixString
in interface TwoDimensionalCounterInterface<K1,K2>
public java.lang.String toMatrixString(int cellSize, java.text.NumberFormat nf)
public double[][] toMatrix(java.util.List<K1> firstKeys, java.util.List<K2> secondKeys)
toMatrix
in interface TwoDimensionalCounterInterface<K1,K2>
public java.lang.String toCSVString(java.text.NumberFormat nf)
toCSVString
in interface TwoDimensionalCounterInterface<K1,K2>
public java.util.Set<K2> secondKeySet()
secondKeySet
in interface TwoDimensionalCounterInterface<K1,K2>
public boolean isEmpty()
isEmpty
in interface TwoDimensionalCounterInterface<K1,K2>
public ClassicCounter<Pair<K1,K2>> flatten()
public void addAll(TwoDimensionalCounterInterface<K1,K2> c)
public void subtractAll(TwoDimensionalCounterInterface<K1,K2> c, boolean removeKeys)
public Counter<K1> sumInnerCounter()
public void removeZeroCounts()
public void remove(K1 key)
remove
in interface TwoDimensionalCounterInterface<K1,K2>
public void clear()
public void clean()
public MapFactory<K1,ClassicCounter<K2>> getOuterMapFactory()
public MapFactory<K2,MutableDouble> getInnerMapFactory()
public static <K1,K2> TwoDimensionalCounter<K1,K2> identityHashMapCounter()
public void recomputeTotal()
public static void main(java.lang.String[] args)