Interface MapIndex<K,​V>

  • Type Parameters:
    K - the type of keys in this map
    V - the type of values in this map
    All Superinterfaces:
    StorageIndex
    All Known Implementing Classes:
    MapIndexProxy, ProofMapIndexProxy

    public interface MapIndex<K,​V>
    extends StorageIndex
    A MapIndex is an index that maps keys to values. A map cannot contain duplicate keys; each key corresponds to at most one value.

    The "destructive" methods of the map, i.e., the one that change the map contents, are specified to throw UnsupportedOperationException if the map has been created with a read-only database view.

    This interface prohibits null keys and values.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void clear()
      Removes all of the key-value pairs from the map.
      boolean containsKey​(K key)
      Returns true if this map contains a mapping for the specified key.
      Iterator<MapEntry<K,​V>> entries()
      Returns an iterator over the map entries.
      V get​(K key)
      Returns the value associated with the specified key, or null if there is no mapping for the key.
      default boolean isEmpty()
      Returns true if this map has no entries.
      Iterator<K> keys()
      Returns an iterator over the map keys in lexicographical order.
      void put​(K key, V value)
      Puts a new key-value pair into the map.
      default void putAll​(Map<? extends K,​? extends V> sourceMap)
      Puts all key-value pairs from the given map into this map.
      void remove​(K key)
      Removes the value mapped to the specified key from the map.
      Iterator<V> values()
      Returns an iterator over the map values in lexicographical order of keys.
    • Method Detail

      • containsKey

        boolean containsKey​(K key)
        Returns true if this map contains a mapping for the specified key.
        Throws:
        IllegalStateException - if this map is not valid
      • put

        void put​(K key,
                 V value)
        Puts a new key-value pair into the map. If this map already contains a mapping for the specified key, overwrites the old value with the specified value.
        Parameters:
        key - a storage key
        value - a storage value to associate with the key
        Throws:
        IllegalStateException - if this map is not valid
        IllegalArgumentException - if some property of the key or the value prevents it from being stored in this map
        UnsupportedOperationException - if this map is read-only
      • putAll

        default void putAll​(Map<? extends K,​? extends V> sourceMap)
        Puts all key-value pairs from the given map into this map. Equivalent to a sequence of individual put(K, V) operations.
        Parameters:
        sourceMap - a map to put into this one
        Throws:
        NullPointerException - if the passed map is null or contains a null key or values
        IllegalStateException - if this map is not valid
        IllegalArgumentException - if some property of the key or the value prevents it from being stored in this map
        UnsupportedOperationException - if this map is read-only
      • get

        V get​(K key)
        Returns the value associated with the specified key, or null if there is no mapping for the key.
        Parameters:
        key - a storage key
        Returns:
        the value mapped to the specified key, or null if this map contains no mapping for the key.
        Throws:
        IllegalStateException - if this map is not valid
      • remove

        void remove​(K key)
        Removes the value mapped to the specified key from the map. If there is no such mapping, has no effect.
        Parameters:
        key - a storage key
        Throws:
        IllegalStateException - if this map is not valid
        UnsupportedOperationException - if this map is read-only
      • values

        Iterator<V> values()
        Returns an iterator over the map values in lexicographical order of keys.
        Throws:
        IllegalStateException - if this map is not valid
      • entries

        Iterator<MapEntry<K,​V>> entries()
        Returns an iterator over the map entries. The entries are ordered by keys in lexicographical order.
        Throws:
        IllegalStateException - if this map is not valid
      • isEmpty

        default boolean isEmpty()
        Returns true if this map has no entries.

        Note: there is no size() method because implementations of MapIndex do not currently track the number of entries.