Interface Function<K,​V>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default V apply​(K key)
      This is equivalent to calling get(Object).
      default void clear()
      Removes all associations from this function (optional operation).
      default boolean containsKey​(Object key)
      Returns true if this function contains a mapping for the specified key.
      V get​(Object key)
      Returns the value associated by this function to the specified key.
      default V put​(K key, V value)
      Associates the specified value with the specified key in this function (optional operation).
      default V remove​(Object key)
      Removes this key and the associated value from this function if it is present (optional operation).
      default int size()
      Returns the intended number of keys in this function, or -1 if no such number exists.
    • Method Detail

      • put

        default V put​(K key,
                      V value)
        Associates the specified value with the specified key in this function (optional operation).
        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)
      • get

        V get​(Object key)
        Returns the value associated by this function to the specified key.
        Parameters:
        key - the key.
        Returns:
        the corresponding value, or null if no value was present for the given key.
        See Also:
        Map.get(Object)
      • containsKey

        default boolean containsKey​(Object key)
        Returns true if this function contains a mapping for the specified key.

        Note that for some kind of functions (e.g., hashes) this method will always return true. This default implementation, in particular, always return true.

        Parameters:
        key - the key.
        Returns:
        true if this function associates a value to key.
        See Also:
        Map.containsKey(Object)
      • remove

        default V remove​(Object key)
        Removes this key and the associated value from this function if it is present (optional operation).
        Parameters:
        key - the key.
        Returns:
        the old value, or null if no value was present for the given key.
        See Also:
        Map.remove(Object)
      • size

        default int size()
        Returns the intended number of keys in this function, or -1 if no such number exists.

        Most function implementations will have some knowledge of the intended number of keys in their domain. In some cases, however, this might not be possible. This default implementation, in particular, returns -1.

        Returns:
        the intended number of keys in this function, or -1 if that number is not available.
      • clear

        default void clear()
        Removes all associations from this function (optional operation).
        See Also:
        Map.clear()