it.unimi.dsi.fastutil.objects
Class AbstractReference2ObjectFunction<K,V>

java.lang.Object
  extended by it.unimi.dsi.fastutil.objects.AbstractReference2ObjectFunction<K,V>
All Implemented Interfaces:
Function<K,V>, Reference2ObjectFunction<K,V>, Serializable
Direct Known Subclasses:
AbstractReference2ObjectMap, Reference2ObjectFunctions.EmptyFunction, Reference2ObjectFunctions.Singleton, Reference2ObjectFunctions.SynchronizedFunction, Reference2ObjectFunctions.UnmodifiableFunction

public abstract class AbstractReference2ObjectFunction<K,V>
extends Object
implements Reference2ObjectFunction<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

Field Summary
static long serialVersionUID
           
 
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).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.Function
containsKey, get, size
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Method Detail

defaultReturnValue

public void defaultReturnValue(V rv)
Description copied from interface: Reference2ObjectFunction
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 Reference2ObjectFunction<K,V>
Parameters:
rv - the new default return value.
See Also:
Reference2ObjectFunction.defaultReturnValue()

defaultReturnValue

public V defaultReturnValue()
Description copied from interface: Reference2ObjectFunction
Gets the default return value.

Specified by:
defaultReturnValue in interface Reference2ObjectFunction<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()