it.unimi.dsi.fastutil.objects
Class AbstractObject2ReferenceFunction<K,V>
java.lang.Object
it.unimi.dsi.fastutil.objects.AbstractObject2ReferenceFunction<K,V>
- All Implemented Interfaces:
- Function<K,V>, Object2ReferenceFunction<K,V>, Serializable
- Direct Known Subclasses:
- AbstractObject2ReferenceMap, Object2ReferenceFunctions.EmptyFunction, Object2ReferenceFunctions.Singleton, Object2ReferenceFunctions.SynchronizedFunction, Object2ReferenceFunctions.UnmodifiableFunction
public abstract class AbstractObject2ReferenceFunction<K,V>
- extends Object
- implements Object2ReferenceFunction<K,V>, Serializable
An abstract class providing basic methods for functions implementing a type-specific interface.
Optional operations just throw an UnsupportedOperationException
. Generic versions of accessors delegate to
the corresponding type-specific counterparts following the interface rules
(they take care of returning null
on a missing key).
This class handles directly a default return
value (including methods to access
it). Instances of classes inheriting from this class have just to return
defRetValue
to denote lack of a key in type-specific methods. The value
is serialized.
Implementing subclasses have just to provide type-specific get()
,
type-specific containsKey()
, and size() methods.
- See Also:
- Serialized Form
Method Summary |
void |
clear()
Removes all associations from this function (optional operation). |
V |
defaultReturnValue()
Gets the default return value. |
void |
defaultReturnValue(V rv)
Sets the default return value. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this function (optional operation). |
V |
remove(Object key)
Removes this key and the associated value from this function if it is present (optional operation). |
defaultReturnValue
public void defaultReturnValue(V rv)
- Description copied from interface:
Object2ReferenceFunction
- Sets the default return value.
This value must be returned by type-specific versions of
get()
, put()
and remove()
to
denote that the map does not contain the specified key. It must be
0/false
/null
by default.
- Specified by:
defaultReturnValue
in interface Object2ReferenceFunction<K,V>
- Parameters:
rv
- the new default return value.- See Also:
Object2ReferenceFunction.defaultReturnValue()
defaultReturnValue
public V defaultReturnValue()
- Description copied from interface:
Object2ReferenceFunction
- Gets the default return value.
- Specified by:
defaultReturnValue
in interface Object2ReferenceFunction<K,V>
- Returns:
- the current default return value.
put
public V put(K key,
V value)
- Description copied from interface:
Function
- Associates the specified value with the specified key in this function (optional operation).
- Specified by:
put
in interface Function<K,V>
- Parameters:
key
- the key.value
- the value.
- Returns:
- the old value, or
null
if no value was present for the given key. - See Also:
Map.put(Object,Object)
remove
public V remove(Object key)
- Description copied from interface:
Function
- Removes this key and the associated value from this function if it is present (optional operation).
- Specified by:
remove
in interface Function<K,V>
- Returns:
- the old value, or
null
if no value was present for the given key. - See Also:
Map.remove(Object)
clear
public void clear()
- Description copied from interface:
Function
- Removes all associations from this function (optional operation).
- Specified by:
clear
in interface Function<K,V>
- See Also:
Map.clear()