public class PersistentTreeMap<K,V> extends AbstractUnmodMap<K,V> implements ImSortedMap<K,V>, Serializable
UnmodMap.UnEntry<K,V>
Modifier and Type | Field and Description |
---|---|
static PersistentTreeMap |
EMPTY
Be extremely careful with this because it uses the default comparator, which only works for
items that implement Comparable (have a "natural ordering").
|
Modifier and Type | Method and Description |
---|---|
PersistentTreeMap<K,V> |
assoc(K key,
V val)
Returns a new map with the given key/value added.
|
Comparator<? super K> |
comparator()
Returns the comparator used to order the keys in this map, or null if it uses
Fn2.DEFAULT_COMPARATOR (for compatibility with java.util.SortedMap).
|
static <K extends Comparable<K>,V> |
empty()
Be extremely careful with this because it uses the default comparator, which only works for
items that implement Comparable (have a "natural ordering").
|
static <K,V> PersistentTreeMap<K,V> |
empty(Comparator<? super K> c)
Returns a new empty PersistentTreeMap that will use the specified comparator.
|
Option<UnmodMap.UnEntry<K,V>> |
entry(K key)
Returns an Option of the key/value pair matching the given key, or Option.none() if the key is
not found.
|
ImSortedSet<Map.Entry<K,V>> |
entrySet()
Returns a view of the mappings contained in this map.
|
K |
firstKey()
Returns the first key in this map or throws a NoSuchElementException if the map is empty.
|
Option<UnmodMap.UnEntry<K,V>> |
head()
The first item in this iterable.
|
UnmodSortedIterator<UnmodMap.UnEntry<K,V>> |
iterator()
Returns an iterator over the UnEntries of this map in order.
|
UnmodMap.UnEntry<K,V> |
last()
Returns the last key/value pair in this map, or null if the map is empty.
|
K |
lastKey()
Returns the last key in this map or throws a NoSuchElementException if the map is empty.
|
static <K extends Comparable<K>,V> |
of(Iterable<Map.Entry<K,V>> es)
Returns a new PersistentTreeMap of the given comparable keys and their paired values, skipping
any null Entries.
|
static <K,V> PersistentTreeMap<K,V> |
ofComp(Comparator<? super K> comp,
Iterable<Map.Entry<K,V>> kvPairs)
Returns a new PersistentTreeMap of the specified comparator and the given key/value pairs.
|
int |
size()
Returns the number of key/value mappings 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 end
|
PersistentTreeMap<K,V> |
without(K key)
Returns a new map with the given key/value removed
|
equals
hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
assoc, containsKey, get, getOrElse, headMap, keySet
values
castFromList, castFromSortedMap, castFromSortedSet, equal
clear, compute, computeIfAbsent, computeIfPresent, containsValue, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll
equals, forEach, getOrDefault, hashCode
concat, drop, dropWhile, filter, flatMap, fold, foldUntil, hash, map, precat, take, takeWhile, toString
forEach, spliterator
toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableRrbt, toMutableSet, toMutableSortedMap, toMutableSortedSet
public static final PersistentTreeMap EMPTY
public static <K extends Comparable<K>,V> PersistentTreeMap<K,V> of(Iterable<Map.Entry<K,V>> es)
public static <K,V> PersistentTreeMap<K,V> ofComp(Comparator<? super K> comp, Iterable<Map.Entry<K,V>> kvPairs)
comp
- A comparator (on the keys) that defines the sort order inside the new map. This
becomes a permanent part of the map and all sub-maps or appended maps derived from it. If you
want to use a null key, make sure the comparator treats nulls correctly in all circumstances!kvPairs
- Key/value pairs (to go into the map). In the case of a duplicate key, later
values in the input list 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. Null
k/v pairs will be silently ignored.public static <K extends Comparable<K>,V> PersistentTreeMap<K,V> empty()
public static <K,V> PersistentTreeMap<K,V> empty(Comparator<? super K> c)
public ImSortedSet<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in interface SortedMap<K,V>
entrySet
in interface BaseMap<K,V>
entrySet
in interface ImSortedMap<K,V>
entrySet
in interface UnmodMap<K,V>
entrySet
in interface UnmodSortedMap<K,V>
public ImSortedMap<K,V> subMap(K fromKey, K toKey)
public Option<UnmodMap.UnEntry<K,V>> head()
head
in interface UnmodIterable<UnmodMap.UnEntry<K,V>>
head
in interface Transformable<UnmodMap.UnEntry<K,V>>
public ImSortedMap<K,V> tailMap(K fromKey)
public Comparator<? super K> comparator()
comparator
in interface SortedMap<K,V>
public PersistentTreeMap<K,V> assoc(K key, V val)
assoc
in interface BaseMap<K,V>
assoc
in interface ImSortedMap<K,V>
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.public PersistentTreeMap<K,V> without(K key)
public UnmodSortedIterator<UnmodMap.UnEntry<K,V>> iterator()
iterator
in interface Iterable<UnmodMap.UnEntry<K,V>>
iterator
in interface ImSortedMap<K,V>
iterator
in interface UnmodIterable<UnmodMap.UnEntry<K,V>>
iterator
in interface UnmodSortedIterable<UnmodMap.UnEntry<K,V>>
public K firstKey()
public K lastKey()
public UnmodMap.UnEntry<K,V> last()
public int size()
Copyright © 2018. All rights reserved.