public class MultiCountMap<T> extends Object
String[] ts1 = {"A"};
String[] ts2 = {"A", "B"};
MultiCountMap map = new MultiCountMap();
map.add(ts1);
map.add(ts1);
map.add(ts2, 4); // for some reason we kno this occurs 4x
map.add(ts2);
map.get(ts1); // returns 1.0
map.get(ts2); // returns 5.0
In clean OOP you might have (or should!) create separate objects for the inputs and override hashcode and equals. Yet
this is sometimes just overkill and you simply want to count such occurences but do not want to concatenate the
strings with some magic seprator etc. In this case, this class is for you.Constructor and Description |
---|
MultiCountMap() |
Modifier and Type | Method and Description |
---|---|
double |
add(List<T> ts)
raises the counter vor the given combination
|
double |
add(List<T> ts,
double inc)
raises the counter vor the given combination
|
double |
add(T ts)
raises the counter vor the given combination
|
double |
add(T[] ts)
raises the counter vor the given combination
|
double |
add(T[] ts,
double inc)
raises the counter vor the given combination
|
double |
add(T t,
double inc)
raises the counter vor the given combination
|
void |
clear()
clears all entries
|
double |
get(List<T> ts)
returns the current counter value
|
double |
get(T ts)
returns the current counter value
|
double |
get(T[] ts)
returns the current counter value
|
boolean |
isEmpty()
Checks if the map is empty.
|
double |
set(List<T> ts,
double inc)
sets the counter vor the given combination
|
double |
set(T[] ts,
double inc)
sets the counter vor the given combination
|
double |
set(T t,
double inc)
sets the counter vor the given combination
|
public void clear()
public boolean isEmpty()
public double get(T ts)
ts
- public double get(T[] ts)
ts
- public double add(List<T> ts)
ts
- public double add(T ts)
ts
- public double add(T[] ts)
ts
- public double add(List<T> ts, double inc)
ts
- inc
- public double add(T t, double inc)
ts
- inc
- public double add(T[] ts, double inc)
ts
- inc
- public double set(List<T> ts, double inc)
ts
- inc
- public double set(T t, double inc)
ts
- inc
- public double set(T[] ts, double inc)
ts
- inc
- Copyright © 2012. All Rights Reserved.