java.lang.Object
java.util.AbstractMap<K,V>
org.jhotdraw8.icollection.MutableRedBlackMap<K,V>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Map.Entry<K,,V>> Map<K,,V> NavigableMap<K,,V> SequencedMap<K,,V> SortedMap<K,,V> ReadOnlyMap<K,,V> ReadOnlyNavigableMap<K,,V> ReadOnlySequencedMap<K,,V> ReadOnlySortedMap<K,V>
public class MutableRedBlackMap<K,V>
extends AbstractMap<K,V>
implements NavigableMap<K,V>, ReadOnlyNavigableMap<K,V>, Cloneable, Serializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new empty map, using the natural ordering of its keys.MutableRedBlackMap(Iterable<? extends Map.Entry<? extends K, ? extends V>> m) Constructs a map containing the same entries as in the specifiedIterable, using the natural ordering of its keys.MutableRedBlackMap(@Nullable Comparator<? super K> comparator) Constructs a new empty map, that uses the specified comparator for ordering its keys.MutableRedBlackMap(Map<? extends K, ? extends V> m) Constructs a map containing the same entries as in the specifiedMap, using the natural ordering of its keys.MutableRedBlackMap(SortedMap<? extends K, ? extends V> m) Constructs a map containing the same entries as in the specifiedMap, using the same ordering as used by the provided map. -
Method Summary
Modifier and TypeMethodDescriptionceilingEntry(K key) Returns the least entry in this map with a key greater than or equal to the given key, or null if there is no such entry.ceilingKey(K key) Returns the least entry in this map with a key greater than or equal to the given key, or null if there is no such key.voidclear()clone()@Nullable Comparator<? super K> Returns the comparator used to order the keys in this map, or null if this set uses the natural ordering of its keys.booleancontainsKey(Object key) Returnstrueif this map contains a entry for the specified key.booleancontainsValue(Object value) Returnstrueif this map contains one or more keys to the specified value.entrySet()Gets the first entry in this map ornullif this map is empty.firstKey()floorEntry(K key) Returns the greatest entry in this map with a key less than or equal to the given key, or null if there is no such entry.Returns the greatest key in this map less than or equal to the given key, or null if there is no such key.@Nullable VReturns the value to which the key is mapped, ornullif this map contains no entry for the key.getOrDefault(Object key, V defaultValue) Returns the value to which the key is mapped, or the specified default value if this map contains no entry for the key.higherEntry(K key) Returns the least entry in this map with a key greater than the given key, or null if there is no such entry.Returns the least key in this map greater than the given key, or null if there is no such key.iterator()Returns an iterator over the entries contained in this map.keySet()Gets the last entry in this map ornullif this map is empty.lastKey()lowerEntry(K key) Returns the greatest entry in this map with a key less than the given key, or null if there is no such entry.Returns the greatest key in this map less than the given key, or null if there is no such key.@Nullable VvoidReturns a reversed-order view of this map.@Nullable Vintsize()Returns the number of entries contained in this map..Returns a spliterator over the entries contained in this map.values()Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface java.util.NavigableMap
reversedMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyMap
containsEntry, equals, hashCode, isEmptyMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySequencedMap
asMap, readOnlyEntrySet, readOnlyKeySet, readOnlyValuesMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySortedMap
characteristicsMethods inherited from interface java.util.SequencedMap
sequencedEntrySet, sequencedKeySet, sequencedValues
-
Constructor Details
-
MutableRedBlackMap
public MutableRedBlackMap()Constructs a new empty map, using the natural ordering of its keys. -
MutableRedBlackMap
Constructs a new empty map, that uses the specified comparator for ordering its keys.- Parameters:
comparator- the comparator that will be used to order this map. If null, the natural ordering of the keys is used.
-
MutableRedBlackMap
Constructs a map containing the same entries as in the specifiedMap, using the natural ordering of its keys.- Parameters:
m- a map
-
MutableRedBlackMap
Constructs a map containing the same entries as in the specifiedMap, using the same ordering as used by the provided map.- Parameters:
m- a map
-
MutableRedBlackMap
Constructs a map containing the same entries as in the specifiedIterable, using the natural ordering of its keys.- Parameters:
m- an iterable
-
-
Method Details
-
clone
- Overrides:
clonein classAbstractMap<K,V>
-
lowerEntry
Description copied from interface:ReadOnlyNavigableMapReturns the greatest entry in this map with a key less than the given key, or null if there is no such entry.- Specified by:
lowerEntryin interfaceNavigableMap<K,V> - Specified by:
lowerEntryin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- lower entry or null
-
lowerKey
Description copied from interface:ReadOnlyNavigableMapReturns the greatest key in this map less than the given key, or null if there is no such key.- Specified by:
lowerKeyin interfaceNavigableMap<K,V> - Specified by:
lowerKeyin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- lower key or null
-
floorEntry
Description copied from interface:ReadOnlyNavigableMapReturns the greatest entry in this map with a key less than or equal to the given key, or null if there is no such entry.- Specified by:
floorEntryin interfaceNavigableMap<K,V> - Specified by:
floorEntryin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- floor entry or null
-
floorKey
Description copied from interface:ReadOnlyNavigableMapReturns the greatest key in this map less than or equal to the given key, or null if there is no such key.- Specified by:
floorKeyin interfaceNavigableMap<K,V> - Specified by:
floorKeyin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- floor key or null
-
ceilingEntry
Description copied from interface:ReadOnlyNavigableMapReturns the least entry in this map with a key greater than or equal to the given key, or null if there is no such entry.- Specified by:
ceilingEntryin interfaceNavigableMap<K,V> - Specified by:
ceilingEntryin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- ceiling entry or null
-
ceilingKey
Description copied from interface:ReadOnlyNavigableMapReturns the least entry in this map with a key greater than or equal to the given key, or null if there is no such key.- Specified by:
ceilingKeyin interfaceNavigableMap<K,V> - Specified by:
ceilingKeyin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- ceiling key or null
-
higherEntry
Description copied from interface:ReadOnlyNavigableMapReturns the least entry in this map with a key greater than the given key, or null if there is no such entry.- Specified by:
higherEntryin interfaceNavigableMap<K,V> - Specified by:
higherEntryin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- higher entry or null
-
higherKey
Description copied from interface:ReadOnlyNavigableMapReturns the least key in this map greater than the given key, or null if there is no such key.- Specified by:
higherKeyin interfaceNavigableMap<K,V> - Specified by:
higherKeyin interfaceReadOnlyNavigableMap<K,V> - Parameters:
key- the given key- Returns:
- higher key or null
-
readOnlyReversed
Description copied from interface:ReadOnlySequencedMapReturns a reversed-order view of this map.Changes to the underlying map are visible in the reversed view.
- Specified by:
readOnlyReversedin interfaceReadOnlySequencedMap<K,V> - Returns:
- a reversed-order view of this map
-
firstEntry
Description copied from interface:ReadOnlySequencedMapGets the first entry in this map ornullif this map is empty.- Specified by:
firstEntryin interfaceNavigableMap<K,V> - Specified by:
firstEntryin interfaceReadOnlySequencedMap<K,V> - Specified by:
firstEntryin interfaceSequencedMap<K,V> - Returns:
- the first entry or
null
-
lastEntry
Description copied from interface:ReadOnlySequencedMapGets the last entry in this map ornullif this map is empty.- Specified by:
lastEntryin interfaceNavigableMap<K,V> - Specified by:
lastEntryin interfaceReadOnlySequencedMap<K,V> - Specified by:
lastEntryin interfaceSequencedMap<K,V> - Returns:
- the last entry or
null
-
pollFirstEntry
- Specified by:
pollFirstEntryin interfaceNavigableMap<K,V> - Specified by:
pollFirstEntryin interfaceSequencedMap<K,V>
-
pollLastEntry
- Specified by:
pollLastEntryin interfaceNavigableMap<K,V> - Specified by:
pollLastEntryin interfaceSequencedMap<K,V>
-
descendingMap
- Specified by:
descendingMapin interfaceNavigableMap<K,V>
-
descendingKeySet
- Specified by:
descendingKeySetin interfaceNavigableMap<K,V>
-
subMap
- Specified by:
subMapin interfaceNavigableMap<K,V>
-
headMap
- Specified by:
headMapin interfaceNavigableMap<K,V>
-
tailMap
- Specified by:
tailMapin interfaceNavigableMap<K,V>
-
comparator
Description copied from interface:ReadOnlySortedMapReturns the comparator used to order the keys in this map, or null if this set uses the natural ordering of its keys.- Specified by:
comparatorin interfaceReadOnlySortedMap<K,V> - Specified by:
comparatorin interfaceSortedMap<K,V> - Returns:
- comparator or null
-
subMap
-
headMap
-
tailMap
-
firstKey
-
lastKey
-
size
public int size()Description copied from interface:ReadOnlyMapReturns the number of entries contained in this map.. -
containsKey
Description copied from interface:ReadOnlyMapReturnstrueif this map contains a entry for the specified key.- Specified by:
containsKeyin interfaceMap<K,V> - Specified by:
containsKeyin interfaceReadOnlyMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V> - Parameters:
key- a key- Returns:
trueif this map contains a entry for the specified key
-
containsValue
Description copied from interface:ReadOnlyMapReturnstrueif this map contains one or more keys to the specified value.- Specified by:
containsValuein interfaceMap<K,V> - Specified by:
containsValuein interfaceReadOnlyMap<K,V> - Overrides:
containsValuein classAbstractMap<K,V> - Parameters:
value- a value- Returns:
trueif this map maps one or more keys to the specified value
-
get
Description copied from interface:ReadOnlyMapReturns the value to which the key is mapped, ornullif this map contains no entry for the key. -
put
-
remove
-
clear
public void clear() -
toImmutable
-
iterator
Description copied from interface:ReadOnlyMapReturns an iterator over the entries contained in this map. -
spliterator
Description copied from interface:ReadOnlySortedMapReturns a spliterator over the entries contained in this map.- Specified by:
spliteratorin interfaceIterable<K>- Specified by:
spliteratorin interfaceReadOnlyMap<K,V> - Specified by:
spliteratorin interfaceReadOnlySortedMap<K,V> - Returns:
- a spliterator
-
entrySet
-
keySet
-
values
-
getOrDefault
Description copied from interface:ReadOnlyMapReturns the value to which the key is mapped, or the specified default value if this map contains no entry for the key.- Specified by:
getOrDefaultin interfaceMap<K,V> - Specified by:
getOrDefaultin interfaceReadOnlyMap<K,V> - Parameters:
key- a keydefaultValue- a default value- Returns:
- the mapped value or the specified default value
-
putAll
-