Interface ImmutableSequencedMap<K,V>

Type Parameters:
K - the key type
V - the value type
All Superinterfaces:
ImmutableMap<K,V>, Iterable<Map.Entry<K,V>>, ReadOnlyMap<K,V>, ReadOnlySequencedMap<K,V>
All Known Implementing Classes:
ChampVectorMap

public interface ImmutableSequencedMap<K,V> extends ImmutableMap<K,V>, ReadOnlySequencedMap<K,V>
An interface to an immutable map with a well-defined iteration order; the implementation guarantees that the state of the collection does not change.

An interface to an immutable sequenced map provides methods for creating a new immutable sequenced map with added, updated or removed entries, without changing the original immutable sequenced map.

  • Method Details

    • clear

      Description copied from interface: ImmutableMap
      Returns a copy of this map that is empty.
      Specified by:
      clear in interface ImmutableMap<K,V>
      Returns:
      this set instance if it is already empty, or a different set instance that is empty.
    • put

      ImmutableSequencedMap<K,V> put(K key, @Nullable V value)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with the specified entry added or updated.
      Specified by:
      put in interface ImmutableMap<K,V>
      Parameters:
      key - the key of the entry
      value - the value of the entry
      Returns:
      this map instance if it already contains the same entry, or a different map instance with the entry added or updated
    • putFirst

      ImmutableSequencedMap<K,V> putFirst(K key, @Nullable V value)
      Creates an entry for the specified key and value and adds it to the front of the map if an entry for the specified key is not already present. If this map already contains an entry for the specified key, replaces the value and moves the entry to the front.
      Parameters:
      key - the key
      value - the value
      Returns:
      this map instance if no changes are needed, or a different map instance with the applied changes.
    • putLast

      ImmutableSequencedMap<K,V> putLast(K key, @Nullable V value)
      Creates an entry for the specified key and value and adds it to the end of the map if an entry for the specified key is not already present. If this map already contains an entry for the specified key, replaces the value and moves the entry to the end.
      Parameters:
      key - the key
      value - the value
      Returns:
      this map instance if no changes are needed, or a different map instance with the applied changes.
    • putAll

      ImmutableSequencedMap<K,V> putAll(Iterable<? extends Map.Entry<? extends K,? extends V>> c)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with entries from the specified map added or updated.
      Specified by:
      putAll in interface ImmutableMap<K,V>
      Parameters:
      c - another map
      Returns:
      this map instance if it already contains the same entries, or a different map instance with the entries added or updated
    • putKeyValues

      default ImmutableSequencedMap<K,V> putKeyValues(Object... kv)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with entries from the specified map added or updated.
      Specified by:
      putKeyValues in interface ImmutableMap<K,V>
      Parameters:
      kv - a list of alternating keys and values
      Returns:
      this map instance if it already contains the same entries, or a different map instance with the entries added or updated
    • remove

      ImmutableSequencedMap<K,V> remove(K key)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with the specified entry removed.
      Specified by:
      remove in interface ImmutableMap<K,V>
      Parameters:
      key - the key of the entry
      Returns:
      this map instance if it already does not contain the entry, or a different map instance with the entry removed
    • removeAll

      ImmutableSequencedMap<K,V> removeAll(Iterable<? extends K> c)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map except the entries of the specified collection.
      Specified by:
      removeAll in interface ImmutableMap<K,V>
      Parameters:
      c - a collection with keys of entries to be removed from this map
      Returns:
      this map instance if it already does not contain the entries, or a different map instance with the entries removed
    • removeFirst

      default ImmutableSequencedMap<K,V> removeFirst()
      Returns a copy of this map that contains all entries of this map except the first.
      Returns:
      a new map instance with the first element removed
      Throws:
      NoSuchElementException - if this map is empty
    • removeLast

      default ImmutableSequencedMap<K,V> removeLast()
      Returns a copy of this map that contains all entries of this map except the last.
      Returns:
      a new map instance with the last element removed
      Throws:
      NoSuchElementException - if this set is empty
    • retainAll

      ImmutableSequencedMap<K,V> retainAll(Iterable<? extends K> c)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains only entries that are in this map and in the specified collection.
      Specified by:
      retainAll in interface ImmutableMap<K,V>
      Parameters:
      c - a collection with keys of entries to be retained in this map
      Returns:
      this map instance if it has not changed, or a different map instance with entries removed
    • toMutable

      Map<K,V> toMutable()
      Description copied from interface: ImmutableMap
      Returns a mutable copy of this map.
      Specified by:
      toMutable in interface ImmutableMap<K,V>
      Returns:
      a mutable copy.
    • reverse

      default ImmutableSequencedMap<K,V> reverse()
      Returns a reversed copy of this map.

      This operation may be implemented in O(N).

      Use ReadOnlySequencedMap.readOnlyReversed() if you only need to iterate in the reversed sequence over this set.

      Returns:
      a reversed copy of this set.