V
- Type of the associated elementpublic class RadixHamTrie<V> extends java.lang.Object implements IntKeyMap<V>, java.lang.Cloneable
The key is a primitive int and allows all range of integer values.
The data structure is optimal when keys are grouped around a limited range of values with low dispersion. The map is designed to store values associated to a set of bounded int keys.
Can be used as a map with integers as key (Map<Integer, T>
) or a
compact unbounded integer array (Integer[T])
The implementation uses a Radix HAMT over int keys. Each node of the HAMT has 5 bits.
Iteration over its elements is done in preorder and it is sorted in ascending.
Constructor and Description |
---|
RadixHamTrie()
Constructs an empty
RadixHamTrie |
RadixHamTrie(IntKeyMap<? extends V> m)
Constructs a new
RadixHamTrie with the same mappings as the
specified IntKeyMap . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the elements from this map.
|
java.lang.Object |
clone()
Returns a shallow copy of this RadixHamTrie instance: the
elements themselves are not cloned.
|
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified
value.
|
java.util.Set<IntObjectEntry<V>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
boolean |
equals(java.lang.Object o) |
void |
forEach(java.util.function.Consumer<? super IntObjectEntry<V>> action) |
void |
forEach(IntObjectConsumer<V> action)
Performs the given action for each pair of element of the map until all
elements have been processed or the action throws an exception.
|
void |
forEachKey(java.util.function.IntConsumer action)
Performs the given action to each int key element of the map until all
elements have been processed or the action throws an exception.
|
V |
get(int key)
Returns the value to which the specified key is mapped, or
null
if this map contains no mapping for the key. |
int |
hashCode() |
java.util.Iterator<IntObjectEntry<V>> |
iterator() |
java.util.Set<java.lang.Integer> |
keySet()
Returns a
Set view of the keys contained in this map. |
V |
put(int key,
V value)
Associates the specified value with the specified key in this int keyed
map If the map previously contained a mapping for the key, the old value
is replaced by the specified value.
|
V |
remove(int key)
Removes the specified element from this map if it is present.
|
int |
size()
Returns the number of elements in this map (its cardinality).
|
java.util.Spliterator<IntObjectEntry<V>> |
spliterator() |
java.lang.String |
toString() |
java.util.Collection<V> |
values()
Returns a
Collection view of the values contained in this map. |
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, getOrDefault, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, stream
public V put(int key, V value)
IntKeyMap
m.containsKey(k)
would return true.)public V get(int key)
IntKeyMap
null
if this map contains no mapping for the key.public V remove(int key)
IntKeyMap
public void forEachKey(java.util.function.IntConsumer action)
IntKeyMap
forEachKey
in interface IntKeyMap<V>
action
- The action to be performed for each int key elementpublic boolean containsValue(java.lang.Object value)
IntKeyMap
containsValue
in interface IntKeyMap<V>
value
- value whose presence in this map is to be testedpublic int size()
IntKeyMap
public void clear()
IntKeyMap
public java.lang.Object clone()
clone
in class java.lang.Object
public void forEach(IntObjectConsumer<V> action)
IntKeyMap
public void forEach(java.util.function.Consumer<? super IntObjectEntry<V>> action)
forEach
in interface java.lang.Iterable<IntObjectEntry<V>>
public java.util.Iterator<IntObjectEntry<V>> iterator()
iterator
in interface java.lang.Iterable<IntObjectEntry<V>>
public java.util.Spliterator<IntObjectEntry<V>> spliterator()
spliterator
in interface IntKeyMap<V>
spliterator
in interface java.lang.Iterable<IntObjectEntry<V>>
public java.util.Collection<V> values()
IntKeyMap
Collection
view of the values contained in this map.
The collection is backed by the map, so changes to the map are reflected
in the collection. If the map is modified while an iteration over the
collection is in progress, the results of the iteration are undefined.
The collection doesn't support element removal.public java.util.Set<java.lang.Integer> keySet()
IntKeyMap
Set
view of the keys contained in this map. The set is
backed by the map, so changes to the map are reflected in the set. If the
map is modified while an iteration over the set is in progress the
results of the iteration are undefined. The set doesn't support element
removal.public java.util.Set<IntObjectEntry<V>> entrySet()
IntKeyMap
Set
view of the mappings contained in this map. The set
is backed by the map, so changes to the map are reflected in the set. If
the map is modified while an iteration over the set is in progress the
results of the iteration are undefined.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object