This map is immutable, and designed to provide a map implementation that is only used to iterate over its entries. Each entry in this map is dynamically generated based on an entry in the underlying set.
Any method that is not the size(), isEmpty(), Map.forEach(
Important: Implementations should ensure that the transformed keys still stay unique in the map, as they was in the subject set. Violating this may result in undefined behaviour in some implementations.
An use-case for this kind of map is to create a new Map with the given entries without pre-allocating the transformed entries beforehand.
Example:
A new map is created from a set of strings that have the parsed integers as values for it.
Set<String> set = ...; Map<String, Integer> nmap = new TreeMap<>(new SetTransformingMap<String, String, Integer>(set) { @Override protected Map.Entry<String, Integer> transformEntry(String e) { return ImmutableUtils.makeImmutableMapEntry(e, Integer.parseInt(e); } });Constructing a map in this way instead of calling Map.put(
public | SetTransformingMap( Creates a new instance with the given set. |
public Set< | entrySet() Returns a Set view of the mappings contained in this map. |
public boolean | isEmpty() Returns true if this map contains no key-value mappings. |
public int | size() Returns the number of key-value mappings in this map. |
protected abstract Entry< | transformEntry( Transforms the set element to the map entry. |
From: AbstractMap< |
From: Object |
From: Map< |
null
.