Function<K,V>, java.util.function.Function<K,V>, java.util.Map<K,V>, Reference2ReferenceFunction<K,V>Reference2ReferenceSortedMap<K,V>AbstractReference2ReferenceMap, AbstractReference2ReferenceSortedMap, Reference2ReferenceArrayMap, Reference2ReferenceLinkedOpenHashMap, Reference2ReferenceMaps.EmptyMap, Reference2ReferenceMaps.Singleton, Reference2ReferenceMaps.SynchronizedMap, Reference2ReferenceMaps.UnmodifiableMap, Reference2ReferenceOpenCustomHashMap, Reference2ReferenceOpenHashMap, Reference2ReferenceSortedMaps.EmptySortedMap, Reference2ReferenceSortedMaps.Singleton, Reference2ReferenceSortedMaps.SynchronizedSortedMap, Reference2ReferenceSortedMaps.UnmodifiableSortedMappublic interface Reference2ReferenceMap<K,V> extends Reference2ReferenceFunction<K,V>, java.util.Map<K,V>
Map; provides some additional methods that use
polymorphism to avoid (un)boxing, and handling of a default return value.
Besides extending the corresponding type-specific
function, this interface
strengthens Map.entrySet(), keySet() and values().
Moreover, a number of methods, such as size(),
defaultReturnValue(), etc., are un-defaulted as their function
default do not make sense for a map. Maps returning entry sets of type
Reference2ReferenceMap.FastEntrySet support also fast iteration.
A submap or subset may or may not have an independent default return value (which however must be initialized to the default return value of the originator).
Map| Modifier and Type | Interface | Description |
|---|---|---|
static interface |
Reference2ReferenceMap.Entry<K,V> |
A type-specific
Map.Entry; provides some additional methods
that use polymorphism to avoid (un)boxing. |
static interface |
Reference2ReferenceMap.FastEntrySet<K,V> |
An entry set providing fast iteration.
|
| Modifier and Type | Method | Description |
|---|---|---|
default void |
clear() |
Removes all of the mappings from this map (optional operation).
|
boolean |
containsKey(java.lang.Object key) |
Returns true if this function contains a mapping for the specified key.
|
V |
defaultReturnValue() |
Gets the default return value.
|
void |
defaultReturnValue(V rv) |
Sets the default return value (optional operation).
|
default ObjectSet<java.util.Map.Entry<K,V>> |
entrySet() |
Returns a set view of the mappings contained in this map.
|
ReferenceSet<K> |
keySet() |
|
default V |
put(K key,
V value) |
Adds a pair to the map (optional operation).
|
ObjectSet<Reference2ReferenceMap.Entry<K,V>> |
reference2ReferenceEntrySet() |
Returns a type-specific set view of the mappings contained in this map.
|
default V |
remove(java.lang.Object key) |
Removes the mapping with the given key (optional operation).
|
int |
size() |
Returns the number of key/value mappings in this map.
|
ReferenceCollection<V> |
values() |
compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAllgetint size()
Integer.MAX_VALUE elements, returns
Integer.MAX_VALUE.default void clear()
void defaultReturnValue(V rv)
get(),
put() and remove() to denote that the map does not contain
the specified key. It must be null by default.
Warning: Changing this to a non-null value can have
unforeseen consequences. Especially, it breaks compatibility with the
specifications of Java's Map interface. It has to be used
with great care and thorough study of all method comments is recommended.
defaultReturnValue in interface Reference2ReferenceFunction<K,V>rv - the new default return value.defaultReturnValue()V defaultReturnValue()
defaultReturnValue in interface Reference2ReferenceFunction<K,V>ObjectSet<Reference2ReferenceMap.Entry<K,V>> reference2ReferenceEntrySet()
This method is necessary because there is no inheritance along type
parameters: it is thus impossible to strengthen Map.entrySet() so
that it returns an ObjectSet of
type-specific entries (the latter makes it possible to access keys and values
with type-specific methods).
Map.entrySet()default ObjectSet<java.util.Map.Entry<K,V>> entrySet()
Note that this specification strengthens the one given in
Map.entrySet().
default V put(K key, V value)
This default implementation just delegates to the corresponding function method.
put in interface Function<K,V>put in interface java.util.Map<K,V>put in interface Reference2ReferenceFunction<K,V>key - the key.value - the value.Function.put(Object,Object)default V remove(java.lang.Object key)
This default implementation just delegates to the corresponding type-specific–function method.
remove in interface Function<K,V>remove in interface java.util.Map<K,V>remove in interface Reference2ReferenceFunction<K,V>key - the key.Function.remove(Object)ReferenceSet<K> keySet()
Note that this specification strengthens the one given in
Map.keySet().
ReferenceCollection<V> values()
Note that this specification strengthens the one given in
Map.values().
boolean containsKey(java.lang.Object key)