Class AbstractObject2IntFunction<K>

java.lang.Object
it.unimi.dsi.fastutil.objects.AbstractObject2IntFunction<K>
All Implemented Interfaces:
Function<K,Integer>, Object2IntFunction<K>, Serializable, Function<K,Integer>, ToIntFunction<K>
Direct Known Subclasses:
AbstractObject2IntMap, Object2IntFunctions.EmptyFunction, Object2IntFunctions.Singleton, Object2IntFunctions.UnmodifiableFunction

public abstract class AbstractObject2IntFunction<K> extends Object implements Object2IntFunction<K>, Serializable
An abstract class providing basic methods for functions implementing a type-specific interface.

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:
  • Method Details

    • defaultReturnValue

      public void defaultReturnValue(int rv)
      Description copied from interface: Object2IntFunction
      Sets the default return value (optional operation). 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 Object2IntFunction<K>
      Parameters:
      rv - the new default return value.
      See Also:
    • defaultReturnValue

      public int defaultReturnValue()
      Description copied from interface: Object2IntFunction
      Gets the default return value.

      This default implementation just return the default null value of the type (null for objects, 0 for scalars, false for Booleans).

      Specified by:
      defaultReturnValue in interface Object2IntFunction<K>
      Returns:
      the current default return value.