Class IndirectEquiMap<K,V>
java.lang.Object
org.aksw.commons.collections.cluster.IndirectEquiMap<K,V>
- Type Parameters:
K-V-
A map-like key-value data structure where keys can be stated as equivalent, and thus become aliases
of each other.
Keys can be stated as equivalent using stateEqual (raises exception on conflict) or tryStateEqual (returns the conflict).
Clusters can be obtained using getEquivalences() and their associated values can be set using setValue(id, value).
Note, that there is no distinction between null and undef values. In fact, a null value is interpreted
as the absence of a value, and such a cluster token will be removed from the tokenToValue map.
- Author:
- raven
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a key.protected Integerdump()Export the state as a map of the sets of equivalent keys and their associated values.getEquivalences(K key) booleankeySet()voidPuts a new value, overwrites any prior value associated with the key's cluster.protected voidputKeyToken(K key, int token) static <K,V> void putWithoutNull(Map<K, V> map, K key, V value) Method to set a cluster's value.voidstateEqual(Collection<K> keys, V value) State keys to be equal and sets their values.voidstateEqual(K a, K b) State keys to be equal - raises an exception on conflicting values.voidstateEqual(K a, K b, V value) State keys to be equal and sets their values.toString()tryStateEqual(K a, K b) Try to make keys equal.tryStateEqual(K a, K b, V value, boolean overwrite) States an equality between keys.
-
Field Details
-
keyToToken
-
tokenToKeys
-
tokenToValue
-
tokenToKeysView
-
gen
-
-
Constructor Details
-
IndirectEquiMap
public IndirectEquiMap()
-
-
Method Details
-
dump
Export the state as a map of the sets of equivalent keys and their associated values. Mostly intended for unit testing.- Returns:
-
keySet
-
getEquivalences
-
getValue
-
setValue
Method to set a cluster's value. Checks whether the validity of the token, i.e. whether a cluster with that id exists.- Parameters:
token-value-- Returns:
-
getEquivalences
-
putKeyToken
-
tryStateEqual
Try to make keys equal. The response determines whether there ary any conflicts.- Parameters:
a-b-- Returns:
- null on success, otherwise an entry of the key's conflicting values.
-
stateEqual
State keys to be equal - raises an exception on conflicting values.- Parameters:
a-b-
-
stateEqual
State keys to be equal and sets their values. Any conflicts are resolved by setting the cluster values to the provided value.- Parameters:
a-b-value-
-
stateEqual
State keys to be equal and sets their values. Any conflicts are resolved by setting the cluster values to the provided value.- Parameters:
keys-value-
-
tryStateEqual
States an equality between keys. if overwrite is true, conflicts can not occur as they are overwritten with value. Return value is always null. if overwrite is false, in case of conflict the pair of conflicting values is returned Conflicts can be resolved using stateEqual(a, b, value)- Parameters:
a-b-
-
putWithoutNull
-
add
Adds a key. If it already exists, its associated value is left untouched. Note, that this behavior is different from put(key, null) - which overwrites the value with the absence of a value for that key.- Parameters:
key-
-
put
Puts a new value, overwrites any prior value associated with the key's cluster.- Parameters:
key-value-
-
addKey
-
get
-
isEqual
-
toString
-