Interface Map<K,V>

Type Parameters:
K - type of Map domain (key) entries
V - type of Map range (associated value) entries
All Superinterfaces:
Iterable<Map.Pair<K,V>>, MapKernel<K,V>, Standard<Map<K,V>>
All Known Implementing Classes:
Map1L, Map2, Map3, Map4, MapSecondary

public interface Map<K,V> extends MapKernel<K,V>
MapKernel enhanced with secondary methods.
Mathematical Definitions:
RANGE(
  m: PARTIAL_FUNCTION
 ): finite set of V satisfies
 for all value: V (value is in RANGE(m) iff
  there exists key: K ((key, value) is in m))
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A map entry (key-value pair).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Combines m with this.
    boolean
    hasValue(V value)
    Reports whether there is a pair in this whose second component is value.
    key(V value)
    Reports a key associated with value in this.
    replaceValue(K key, V value)
    Replaces the value associated with key in this with value and returns the old value.
    boolean
    Reports whether this and m have any keys in common.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface components.map.MapKernel

    add, hasKey, remove, removeAny, size, value

    Methods inherited from interface components.standard.Standard

    clear, newInstance, transferFrom
  • Method Details

    • replaceValue

      V replaceValue(K key, V value)
      Replaces the value associated with key in this with value and returns the old value.
      Parameters:
      key - the key whose associated value is replaced
      value - the value replacing the old one
      Returns:
      the old value associated with the given key
      Aliases:
      reference value
      Updates:
      this
      Requires:
      key is in DOMAIN(this)
      Ensures:
      this = (#this \ {(key, replaceValue)}) union {(key, value)}  and
      (key, replaceValue) is in #this
    • key

      K key(V value)
      Reports a key associated with value in this. Note that the key returned generally should not be changed at all via this aliased reference, and if it is then it definitely must not be changed in such a way that it equals another key in the map from which it was obtained.
      Parameters:
      value - the value whose associated key is to be reported
      Returns:
      a key associated with value
      Aliases:
      reference returned by key
      Requires:
      value is in RANGE(this)
      Ensures:
      (key, value) is in this
    • hasValue

      boolean hasValue(V value)
      Reports whether there is a pair in this whose second component is value.
      Parameters:
      value - the value to be checked
      Returns:
      true iff there is a pair in this whose second component is value
      Ensures:
      hasValue = (value is in RANGE(this))
    • sharesKeyWith

      boolean sharesKeyWith(Map<K,V> m)
      Reports whether this and m have any keys in common.
      Parameters:
      m - the Map to be checked against this
      Returns:
      true iff there are keys in common
      Ensures:
      sharesKeyWith = (DOMAIN(this) intersection DOMAIN(m) /= {})
    • combineWith

      void combineWith(Map<K,V> m)
      Combines m with this.
      Parameters:
      m - the Map to be combined with this
      Updates:
      this
      Clears:
      m
      Requires:
      DOMAIN(this) intersection DOMAIN(m) = {}
      Ensures:
      this = #this union #m