Interface UnmodMap<K,​V>

    • Method Detail

      • clear

        @Deprecated
        default void clear()
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        clear in interface Map<K,​V>
      • compute

        @Deprecated
        default V compute​(K key,
                          @NotNull
                          @NotNull BiFunction<? super K,​? super V,​? extends V> remappingFunction)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        compute in interface Map<K,​V>
      • computeIfAbsent

        @Deprecated
        default V computeIfAbsent​(K key,
                                  @NotNull
                                  @NotNull Function<? super K,​? extends V> mappingFunction)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        computeIfAbsent in interface Map<K,​V>
      • computeIfPresent

        @Deprecated
        default V computeIfPresent​(K key,
                                   @NotNull
                                   @NotNull BiFunction<? super K,​? super V,​? extends V> remappingFunction)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        computeIfPresent in interface Map<K,​V>
      • containsValue

        default boolean containsValue​(Object value)
        Most maps are not designed for this - the default implementation has O(n) performance.
        Specified by:
        containsValue in interface Map<K,​V>
      • entrySet

        @NotNull
        default @NotNull UnmodSet<Map.Entry<K,​V>> entrySet()
        Returns a view of the mappings contained in this map. The set will contain UnmodMap.UnEntry items, but that return signature is illegal in Java, so you'll just have to remember. An UnmodMap is iterable, so this method is probably not nearly as useful as it once was.
        Specified by:
        entrySet in interface Map<K,​V>
      • isEmpty

        default boolean isEmpty()
        Specified by:
        isEmpty in interface Map<K,​V>
      • keySet

        @NotNull
        default @NotNull UnmodSet<K> keySet()
        Returns a view of the keys contained in this map. An UnmodMap is iterable, so this method is probably not nearly as useful as it once was.
        Specified by:
        keySet in interface Map<K,​V>
      • keyIterator

        @NotNull
        default @NotNull UnmodIterator<K> keyIterator()
      • valIterator

        @NotNull
        default @NotNull UnmodIterator<V> valIterator()
      • merge

        @Deprecated
        default V merge​(K key,
                        @NotNull
                        V value,
                        @NotNull
                        @NotNull BiFunction<? super V,​? super V,​? extends V> remappingFunction)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        merge in interface Map<K,​V>
      • putAll

        @Deprecated
        default void putAll​(@NotNull
                            @NotNull Map<? extends K,​? extends V> m)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        putAll in interface Map<K,​V>
      • putIfAbsent

        @Deprecated
        default V putIfAbsent​(K key,
                              V value)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        putIfAbsent in interface Map<K,​V>
      • remove

        @Deprecated
        default V remove​(Object key)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        remove in interface Map<K,​V>
      • remove

        @Deprecated
        default boolean remove​(Object key,
                               Object value)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        remove in interface Map<K,​V>
      • replace

        @Deprecated
        default boolean replace​(K key,
                                V oldValue,
                                V newValue)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        replace in interface Map<K,​V>
      • replace

        @Deprecated
        default V replace​(K key,
                          V value)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        replace in interface Map<K,​V>
      • replaceAll

        @Deprecated
        default void replaceAll​(BiFunction<? super K,​? super V,​? extends V> function)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        replaceAll in interface Map<K,​V>
      • values

        @Deprecated
        @NotNull
        default @NotNull UnmodCollection<V> values()
        Deprecated.
        This method has been deprecated because it is impossible to implement equals() or hashCode() on the resulting collection, and calling this method is probably at least a missed opportunity, if not an outright error. Use an UnmodMap as an UnmodIterable<UnmodMap.UnEntry> instead. If you don't care about eliminating duplicate values, and want a compatible return type call:
        myMap.map((UnEntry<K,V> entry) -> entry.getValue())
                     .toImSet();
        If you want to keep a count of duplicates, try something like this, but it has a different signature:
        ImMap<V,Integer> valueCounts = myMap.fold(PersistentHashMap.empty(),
                             (ImMap<V,Integer> accum, UnEntry<K,V> origEntry) -> {
                                     V inVal = origEntry.getValue();
                                     return accum.assoc(inVal,
                                                        accum.getOrElse(inVal, 0) + 1);
                                 });
        You really shouldn't turn values() into a List, because a List has order and an unsorted Map is unordered by key, and especially unordered by value. On a SortedMap, List is the proper return type. java.util.HashMap.values() returns an instance of java.util.HashMap.Values which does *not* have equals() or hashCode() defined. This is because List.equals() and Set.equals() return not-equal when compared to a Collection. There is no good way to implement a reflexive equals with both of those because they are just too different. Ultimately, Collection just isn't specific enough to instantiate, but we do it anyway here for backward compatibility. We don't implement equals() or hashCode() either because the result could have duplicates. If the Map isn't sorted, the result could have random ordering.
        Specified by:
        values in interface Map<K,​V>