Package org.organicdesign.fp.collections
Interface ImSortedMap<K,V>
-
- All Superinterfaces:
BaseMap<K,V>,Iterable<UnmodMap.UnEntry<K,V>>,Map<K,V>,Sized,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
Map.Entry<K extends Object,V extends Object>
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodIterable
UnmodIterable.UnIterable
-
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 @NotNull ImSortedMap<K,V>assoc(Map.Entry<K,V> entry)Returns a new map with an immutable copy of the given entry added@NotNull ImSortedMap<K,V>assoc(K key, V val)Returns a new map with the given key/value added.default booleancontainsKey(Object key)@NotNull Option<UnmodMap.UnEntry<K,V>>entry(K key)Returns an option of the key/value pair associated with this key@NotNull ImSortedSet<Map.Entry<K,V>>entrySet()Returns a view of the mappings contained in this map.default Vget(Object key)default VgetOrElse(K key, V notFound)default @NotNull ImSortedMap<K,V>headMap(K toKey)Return the elements in this map up (but excluding) to the given element@NotNull UnmodSortedIterator<UnmodMap.UnEntry<K,V>>iterator()Returns an iterator over the UnEntries of this map in order.default @NotNull ImSortedSet<K>keySet()Returns a view of the keys contained in this map.@NotNull ImSortedMap<K,V>subMap(K fromKey, K toKey)Return the elements in this map from the start element (inclusive) to the end element (exclusive)@NotNull ImSortedMap<K,V>tailMap(K fromKey)Return the elements in this from the given element to the end@NotNull ImSortedMap<K,V>without(K key)Returns a new map with the given key/value removed-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.SortedMap
comparator, firstKey, lastKey
-
Methods inherited from interface org.organicdesign.fp.xform.Transformable
any, toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutList, toMutMap, toMutRrbt, toMutSet, toMutSortedMap, toMutSortedSet
-
Methods inherited from interface org.organicdesign.fp.collections.UnmodIterable
concat, drop, dropWhile, filter, flatMap, fold, foldUntil, head, map, precat, take, takeWhile, whereNonNull
-
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
@NotNull @NotNull 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(Object key)
- Specified by:
containsKeyin interfaceBaseMap<K,V>- Specified by:
containsKeyin interfaceMap<K,V>
-
entrySet
@NotNull @NotNull ImSortedSet<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.
-
headMap
@NotNull default @NotNull ImSortedMap<K,V> headMap(K toKey)
Return the elements in this map up (but excluding) to the given element
-
iterator
@NotNull @NotNull UnmodSortedIterator<UnmodMap.UnEntry<K,V>> iterator()
Returns an iterator over the UnEntries of this map in order.- Specified by:
iteratorin interfaceIterable<K>- Specified by:
iteratorin interfaceUnmodIterable<K>- Specified by:
iteratorin interfaceUnmodSortedIterable<K>- Returns:
- an Iterator.
-
keySet
@NotNull default @NotNull ImSortedSet<K> keySet()
Returns a view of the keys contained in this map.
-
subMap
@NotNull @NotNull 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
@NotNull @NotNull ImSortedMap<K,V> tailMap(K fromKey)
Return the elements in this from the given element to the end
-
assoc
@NotNull @NotNull 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
@NotNull default @NotNull ImSortedMap<K,V> assoc(@NotNull Map.Entry<K,V> entry)
Returns a new map with an immutable copy of the given entry added
-
-