
org.organicdesign.fp.collections.ImMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Paguro Show documentation
Show all versions of Paguro Show documentation
Immutable Clojure collections and a Transformation abstraction for Java 8+, immutably, type-safely, and with good performance.
package org.organicdesign.fp.collections;
import java.util.Map;
/** An immutable map with no guarantees about its ordering. */
public interface ImMap extends BaseUnsortedMap {
/** Returns a new map with the given key/value added */
@Override ImMap assoc(K key, V val);
/** Returns a new map with an immutable copy of the given entry added */
@Override default ImMap assoc(Map.Entry entry) {
return assoc(entry.getKey(), entry.getValue());
}
/** Returns a new map with the given key/value removed */
@Override ImMap without(K key);
/**
Returns a view of the mappings contained in this map. The set should actually contain
UnmodMap.Entry items, but that return signature is illegal in Java, so you'll just have to
remember.
*/
@Override default ImSet> entrySet() {
return map(e -> (Map.Entry) e)
.toImSet();
}
/** Returns an immutable view of the keys contained in this map. */
@Override default ImSet keySet() {
return mutable().keySet().immutable();
}
/** Returns a mutable version of this mutable map. */
MutableMap mutable();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy