ai.libs.jaicore.basic.Maps Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaicore-basic Show documentation
Show all versions of jaicore-basic Show documentation
Fundamental utils required by many other starlibs projects.
package ai.libs.jaicore.basic;
import java.util.Map;
public class Maps {
/**
* Forbid to create an object of ListHelper as there are only static methods allowed here.
*/
private Maps() {
// intentionally do nothing
}
public static void increaseCounterInMap(final Map counterMap, final K key) {
if (counterMap.containsKey(key)) {
counterMap.put(key, counterMap.get(key) + 1);
} else {
counterMap.put(key, 1);
}
}
public static void increaseCounterInMap(final Map counterMap, final K key, final int summand) {
if (counterMap.containsKey(key)) {
counterMap.put(key, counterMap.get(key) + summand);
} else {
counterMap.put(key, summand);
}
}
public static void increaseCounterInDoubleMap(final Map counterMap, final K key) {
if (counterMap.containsKey(key)) {
counterMap.put(key, counterMap.get(key) + 1.0);
} else {
counterMap.put(key, 1.0);
}
}
public static void increaseCounterInDoubleMap(final Map counterMap, final K key, final double summand) {
if (counterMap.containsKey(key)) {
counterMap.put(key, counterMap.get(key) + summand);
} else {
counterMap.put(key, summand);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy