com.softicar.platform.common.container.map.number.INumberMap Maven / Gradle / Ivy
Show all versions of platform-common Show documentation
package com.softicar.platform.common.container.map.number;
import com.softicar.platform.common.math.arithmetic.IArithmetic;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* Common interface for all maps containing numeric values.
*
* An {@link INumberMap} is actually just a convenience facade for a regular
* {@link Map}.
*
* @param
* the type of the keys
* @param
* the type of the values
* @author Oliver Richers
*/
public interface INumberMap {
Map getDataContainer();
IArithmetic getArithmetic();
// -------------------- read-only -------------------- //
boolean containsKey(K key);
/**
* Same as {@link #getOrZero}.
*
* @param key
* the key
* @return the corresponding value or zero
*/
V get(K key);
/**
* Returns the corresponding value or the given default value.
*
* @param key
* the key
* @return the corresponding value or the default value
*/
V getOrDefault(K key, V defaultValue);
/**
* Returns the corresponding value or null.
*
* @param key
* the key
* @return the corresponding value or null
*/
V getOrNull(K key);
/**
* Returns the corresponding value or throws an exception.
*
* @param key
* the key
* @return the corresponding value or throws an exception
* @throws RuntimeException
* if no matching value exists in the map
*/
V getOrThrow(K key);
/**
* Returns the corresponding value or zero.
*
* @param key
* the key
* @return the corresponding value or zero
*/
V getOrZero(K key);
boolean isEmpty();
int size();
Set keySet();
Set> entrySet();
Collection values();
// -------------------- mutating -------------------- //
void clear();
void put(K key, V value);
void putAll(Map map);
void putAll(INumberMap map);
V remove(K key);
// -------------------- arithmetics -------------------- //
void add(K key, V value);
void sub(K key, V value);
void add(INumberMap other);
void sub(INumberMap other);
void inc(K key);
void dec(K key);
}