K
- type of hash keyV
- value typepublic class HashCoderMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>
Especially for mutable objects you should take care
of providing a useful copier with either the
HashCoder
argument in
HashCoderMap(HashCoder)
or directly with HashCoderMap(Function)
.
Constructor and Description |
---|
HashCoderMap(java.util.function.Function<K,K> copier)
Constructor for creating a hashmap with keys created from mutable objects.
|
HashCoderMap(HashCodeCalculator<? super K> calculator)
Constructor.
|
HashCoderMap(HashCodeCalculator<? super K> calculator,
Matcher<? super K,? super K> matcher)
Constructor.
|
HashCoderMap(HashCodeCalculator<? super K> calculator,
Matcher<? super K,? super K> matcher,
Function1<K,K> copier)
Constructor.
|
HashCoderMap(HashCoder<K> hashCoder)
Constructor.
|
HashCoderMap(HashCoder<K> hashCoder,
int initialCapacity)
Constructor.
|
HashCoderMap(HashCoder<K> hashCoder,
int initialCapacity,
float loadFactor)
Constructor.
|
HashCoderMap(HashCoder<K> hashCoder,
java.util.Map<? extends K,? extends V> sourceMap)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
HashCoder<? super K> |
getHashCoder()
Get the hash coder used in this map.
|
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
remove(java.lang.Object key) |
int |
size() |
java.util.Collection<V> |
values() |
public HashCoderMap(@NotNull HashCoder<K> hashCoder)
hashCoder
- hash coder used for hashcode calculation,
equality checks and copyingpublic HashCoderMap(@NotNull HashCoder<K> hashCoder, int initialCapacity)
hashCoder
- hash coder used for hashcode calculation,
equality checks and copyinginitialCapacity
- initial map capacitypublic HashCoderMap(@NotNull HashCoder<K> hashCoder, int initialCapacity, float loadFactor)
hashCoder
- hash coder used for hashcode calculation,
equality checks and copyinginitialCapacity
- initial map capacityloadFactor
- map load factorpublic HashCoderMap(@NotNull HashCoder<K> hashCoder, @NotNull java.util.Map<? extends K,? extends V> sourceMap)
hashCoder
- hash coder used forsourceMap
- source map which is copied to this mappublic HashCoderMap(@NotNull HashCodeCalculator<? super K> calculator)
Objects.equals(Object, Object)
for
equality checks.calculator
- hash code calculatorpublic HashCoderMap(@NotNull HashCodeCalculator<? super K> calculator, @NotNull Matcher<? super K,? super K> matcher)
calculator
- hash code calculatormatcher
- equality checker fpr hash keyspublic HashCoderMap(@NotNull HashCodeCalculator<? super K> calculator, @NotNull Matcher<? super K,? super K> matcher, @NotNull Function1<K,K> copier)
calculator
- hash code calculatormatcher
- equality checker fpr hash keyscopier
- copier for keys, useful to decouple the keys from their basically mutable source objectspublic HashCoderMap(@NotNull java.util.function.Function<K,K> copier)
Otherwise this uses the Object.hashCode()
copier
- copier for keys@NotNull public HashCoder<? super K> getHashCoder()
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)