Package org.organicdesign.fp.collections
Interface ImSortedMap<K,V>
-
- All Superinterfaces:
BaseMap<K,V>,java.lang.Iterable<UnmodMap.UnEntry<K,V>>,java.util.Map<K,V>,Sized,java.util.SortedMap<K,V>,Transformable<UnmodMap.UnEntry<K,V>>,UnmodIterable<UnmodMap.UnEntry<K,V>>,UnmodMap<K,V>,UnmodSortedIterable<UnmodMap.UnEntry<K,V>>,UnmodSortedMap<K,V>
- All Known Implementing Classes:
PersistentTreeMap
public interface ImSortedMap<K,V> extends UnmodSortedMap<K,V>, BaseMap<K,V>
An immutable sorted map.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodMap
UnmodMap.UnEntry<K,V>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ImSortedMap<K,V>assoc(java.util.Map.Entry<K,V> entry)Returns a new map with an immutable copy of the given entry addedImSortedMap<K,V>assoc(K key, V val)Returns a new map with the given key/value added.default booleancontainsKey(java.lang.Object key)Option<UnmodMap.UnEntry<K,V>>entry(K key)Returns an option of the key/value pair associated with this keyImSortedSet<java.util.Map.Entry<K,V>>entrySet()Returns a view of the mappings contained in this map.default Vget(java.lang.Object key)default VgetOrElse(K key, V notFound)default ImSortedMap<K,V>headMap(K toKey)Return the elements in this map up (but excluding) to the given elementUnmodSortedIterator<UnmodMap.UnEntry<K,V>>iterator()Returns an iterator over the UnEntries of this map in order.default ImSortedSet<K>keySet()Returns a view of the keys contained in this map.ImSortedMap<K,V>subMap(K fromKey, K toKey)Return the elements in this map from the start element (inclusive) to the end element (exclusive)ImSortedMap<K,V>tailMap(K fromKey)Return the elements in this from the given element to the endImSortedMap<K,V>without(K key)Returns a new map with the given key/value removed-
Methods inherited from interface org.organicdesign.fp.xform.Transformable
toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableRrbt, toMutableSet, toMutableSortedMap, toMutableSortedSet
-
Methods inherited from interface org.organicdesign.fp.collections.UnmodIterable
concat, drop, dropWhile, filter, flatMap, fold, foldUntil, head, map, precat, take, takeWhile
-
Methods inherited from interface org.organicdesign.fp.collections.UnmodMap
clear, compute, computeIfAbsent, computeIfPresent, containsValue, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll
-
Methods inherited from interface org.organicdesign.fp.collections.UnmodSortedMap
keyIterator, valIterator, values
-
-
-
-
Method Detail
-
entry
Option<UnmodMap.UnEntry<K,V>> entry(K key)
Description copied from interface:BaseMapReturns an option of the key/value pair associated with this key
-
containsKey
default boolean containsKey(java.lang.Object key)
-
entrySet
ImSortedSet<java.util.Map.Entry<K,V>> entrySet()
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.
-
get
default V get(java.lang.Object key)
-
headMap
default ImSortedMap<K,V> headMap(K toKey)
Return the elements in this map up (but excluding) to the given element
-
iterator
UnmodSortedIterator<UnmodMap.UnEntry<K,V>> iterator()
Returns an iterator over the UnEntries of this map in order.- Specified by:
iteratorin interfacejava.lang.Iterable<K>- Specified by:
iteratorin interfaceUnmodIterable<K>- Specified by:
iteratorin interfaceUnmodSortedIterable<K>- Returns:
- an Iterator.
-
keySet
default ImSortedSet<K> keySet()
Returns a view of the keys contained in this map.
-
subMap
ImSortedMap<K,V> subMap(K fromKey, K toKey)
Return the elements in this map from the start element (inclusive) to the end element (exclusive)
-
tailMap
ImSortedMap<K,V> tailMap(K fromKey)
Return the elements in this from the given element to the end
-
assoc
ImSortedMap<K,V> assoc(K key, V val)
Returns a new map with the given key/value added. If the key exists in this map, the new value overwrites the old one. If the key exists with the same value (based on the address of that value in memory, not an equals test), the old map is returned unchanged.- Specified by:
associn interfaceBaseMap<K,V>- Parameters:
key- the key used to look up the value. In the case of a duplicate key, later values overwrite the earlier ones. The resulting map can contain zero or one null key (if your comparator knows how to sort nulls) and any number of null values.val- the value to store in this key.- Returns:
- a new PersistentTreeMap of the specified comparator and the given key/value pairs
-
assoc
default ImSortedMap<K,V> assoc(java.util.Map.Entry<K,V> entry)
Returns a new map with an immutable copy of the given entry added
-
-