Class HashMap<K,​V>

  • All Implemented Interfaces:
    Iterable<Pair<K,​V>>, Map<K,​V>, Traversable<Pair<K,​V>>, java.lang.Iterable<Pair<K,​V>>

    public class HashMap<K,​V>
    extends AbstractMap<K,​V>
    HashMap is an implementation of Map based on a hash trie.

    The underlying implementation is a port of Scala's HashMap which is an implementation of a hash array mapped trie.

    • Constructor Detail

      • HashMap

        public HashMap()
    • Method Detail

      • empty

        @NotNull
        public static <K,​V> @NotNull HashMap<K,​V> empty()
      • containsKey

        public boolean containsKey​(@NotNull
                                   K key)
        Description copied from interface: Map
        Returns true if this map contains the specified key.
      • put

        @NotNull
        public @NotNull HashMap<K,​V> put​(@NotNull
                                               K key,
                                               V value)
        Description copied from interface: Map
        Returns a map with the value specified associated to the key specified.

        If value already exists for the key, it will be replaced.

      • get

        @Nullable
        public V get​(@NotNull
                     K key)
        Description copied from interface: Map
        Returns the value associated with the key or null if the no value exists with the key specified.
      • remove

        @NotNull
        public @NotNull HashMap<K,​V> remove​(@NotNull
                                                  K key)
        Description copied from interface: Map
        Returns a map with the value associated with the key removed if it exists.
      • size

        public int size()
        Description copied from interface: Traversable
        Returns the size of the collection.

        Warning: infinite collections are possible, as are collections that require traversal to calculate the size.

        Specified by:
        size in interface Traversable<K>
        Overrides:
        size in class AbstractTraversable<Pair<K,​V>>
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<Pair<K,​V>> iterator()