public interface Object2ReferenceMap<K,V> extends Object2ReferenceFunction<K,V>, 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 Object2ReferenceMap.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 and Description |
|---|---|
static interface |
Object2ReferenceMap.Entry<K,V>
A type-specific
Map.Entry; provides some additional methods
that use polymorphism to avoid (un)boxing. |
static interface |
Object2ReferenceMap.FastEntrySet<K,V>
An entry set providing fast iteration.
|
| Modifier and Type | Method and Description |
|---|---|
default void |
clear()
Removes all of the mappings from this map (optional operation).
|
boolean |
containsKey(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<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this map.
|
ObjectSet<K> |
keySet()
Note that this specification strengthens the one given in
Map.keySet(). |
ObjectSet<Object2ReferenceMap.Entry<K,V>> |
object2ReferenceEntrySet()
Returns a type-specific set view of the mappings contained in this map.
|
default V |
put(K key,
V value)
Adds a pair to the map (optional operation).
|
default V |
remove(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()
Note that this specification strengthens the one given in
Map.values(). |
getcompute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAllint size()
Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.default void clear()
clear in interface Map<K,V>UnsupportedOperationException - if the clear() operation is not supported by this mapMap.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 Object2ReferenceFunction<K,V>rv - the new default return value.defaultReturnValue()V defaultReturnValue()
defaultReturnValue in interface Object2ReferenceFunction<K,V>ObjectSet<Object2ReferenceMap.Entry<K,V>> object2ReferenceEntrySet()
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<Map.Entry<K,V>> entrySet()
Note that this specification strengthens the one given in Map.entrySet().
entrySet in interface Map<K,V>Map.entrySet()default V put(K key, V value)
This default implementation just delegates to the corresponding function method.
put in interface Map<K,V>put in interface Object2ReferenceFunction<K,V>key - the key.value - the value.Function.put(Object,Object)default V remove(Object key)
This default implementation just delegates to the corresponding type-specific–function method.
remove in interface Map<K,V>remove in interface Object2ReferenceFunction<K,V>key - the key.Function.remove(Object)ObjectSet<K> keySet()
Note that this specification strengthens the one given in Map.keySet().
keySet in interface Map<K,V>Map.keySet()ReferenceCollection<V> values()
Note that this specification strengthens the one given in Map.values().
values in interface Map<K,V>Map.values()boolean containsKey(Object key)
containsKey in interface Map<K,V>key - the key.key.Map.containsKey(Object)