All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.libs.jaicore.basic.Maps Maven / Gradle / Ivy

There is a newer version: 0.2.7
Show newest version
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