Class PersistentHashMap<K,​V>

    • Method Detail

      • empty

        @NotNull
        public static <K,​V> @NotNull PersistentHashMap<K,​V> empty()
      • emptyMutable

        @NotNull
        public static <K,​V> @NotNull PersistentHashMap.MutHashMap<K,​V> emptyMutable()
        Works around some type inference limitations of Java 8.
      • empty

        @NotNull
        public static <K,​V> @NotNull PersistentHashMap<K,​V> empty​(@Nullable
                                                                              @Nullable Equator<K> e)
      • emptyMutable

        @NotNull
        public static <K,​V> @NotNull PersistentHashMap.MutHashMap<K,​V> emptyMutable​(Equator<K> e)
        Works around some type inference limitations of Java 8.
      • ofEq

        @NotNull
        public static <K,​V> @NotNull PersistentHashMap<K,​V> ofEq​(Equator<K> eq,
                                                                             @Nullable
                                                                             @Nullable Iterable<Map.Entry<K,​V>> es)
        Returns a new PersistentHashMap of the given keys and their paired values, skipping any null Entries.
      • of

        @NotNull
        public static <K,​V> @NotNull PersistentHashMap<K,​V> of​(@Nullable
                                                                           @Nullable Iterable<Map.Entry<K,​V>> kvPairs)
        Returns a new PersistentHashMap of the given keys and their paired values. There is also a varargs version of this method: StaticImports.map(Map.Entry...). Use the StaticImports.tup(Object, Object) method to define key/value pairs briefly and easily.
        Parameters:
        kvPairs - Key/value pairs (to go into the map). In the case of a duplicate key, later values in the input list overwrite the earlier ones. The resulting map can contain zero or one null key and any number of null values. Null k/v pairs will be silently ignored.
        Returns:
        a new PersistentHashMap of the given key/value pairs
      • equator

        @NotNull
        public @NotNull Equator<K> equator()
        Returns the Equator used by this map for equals comparisons and hashCodes
        Specified by:
        equator in interface BaseUnsortedMap<K,​V>
      • assoc

        @NotNull
        public @NotNull PersistentHashMap<K,​V> assoc​(K key,
                                                           V val)
        Description copied from interface: ImMap
        Returns a new map with the given key/value added
        Specified by:
        assoc in interface BaseMap<K,​V>
        Specified by:
        assoc in interface ImMap<K,​V>
      • entry

        @NotNull
        public @NotNull Option<UnmodMap.UnEntry<K,​V>> entry​(K key)
        Description copied from interface: BaseMap
        Returns an option of the key/value pair associated with this key
        Specified by:
        entry in interface BaseMap<K,​V>
      • iterator

        @NotNull
        public @NotNull UnmodIterator<UnmodMap.UnEntry<K,​V>> iterator()
        Description copied from interface: UnmodIterable
        A one-time use, mutable, not-thread-safe way to get each value of the underling collection in turn. I experimented with various thread-safe alternatives, but the JVM is optimized around iterators so this is the lowest common denominator of collection iteration, even though iterators are inherently mutable.
        Specified by:
        iterator in interface Iterable<K>
        Specified by:
        iterator in interface UnmodIterable<K>
      • size

        public int size()
        Returns the number of items in this collection or iterable.
        Specified by:
        size in interface Map<K,​V>
        Specified by:
        size in interface Sized
      • without

        @NotNull
        public @NotNull PersistentHashMap<K,​V> without​(K key)
        Description copied from interface: ImMap
        Returns a new map with the given key/value removed
        Specified by:
        without in interface BaseMap<K,​V>
        Specified by:
        without in interface ImMap<K,​V>