java.lang.Object
org.apache.jena.mem.collection.FastHashBase<K>
org.apache.jena.mem.collection.FastHashMap<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
JenaMap<K,,V> JenaMapIndexed<K,,V> JenaMapSetCommon<K>,Sized
- Direct Known Subclasses:
FastHashedBunchMap,NodesToBitmapsMap,NodesToIndices
Hash map specialization built on top of
FastHashBase.
Grows on demand but never shrinks, does not guarantee iteration order,
does not allow null keys, and is not thread-safe.
Optimized for fast add / containsKey / stream /
iterate operations. Removal is somewhat slower than in
HashMap because of the back-shifting performed on the
probe table. Iteration speed does not recover after many removals because
the dense keys array is not compacted.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.jena.mem.collection.FastHashBase
FastHashBase.KeyAndIndexConsumer<K> -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all the elements from this collection (optional operation).voidcompute(K key, UnaryOperator<V> valueProcessor) Compute a value for a key.computeIfAbsent(K key, Supplier<V> absentValueSupplier) Compute a value for a key if the key is not present.Get the value associated with the provided key.getOrDefault(K key, V defaultValue) Get the value associated with the provided key, or a default value if the key is not present.getValueAt(int i) Returns the value at the given index.voidPut a key-value pair into the map.intputAndGetIndex(K key, V value) Put a key-value pair and return the index of the affected entry.booleanTry to put a key-value pair into the map.Get an iterator over the values in the map.Get a spliterator over the values in the map.Methods inherited from class org.apache.jena.mem.collection.FastHashBase
anyMatch, anyMatchRandomOrder, containsKey, forEachKey, getKeyAt, indexOf, isEmpty, keyIterator, keySpliterator, removeAndGetIndex, removeUnchecked, removeUnchecked, size, tryRemove, tryRemoveMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.jena.mem.collection.JenaMap
valueStream, valueStreamParallelMethods inherited from interface org.apache.jena.mem.collection.JenaMapIndexed
getKeyAt, indexOfMethods inherited from interface org.apache.jena.mem.collection.JenaMapSetCommon
anyMatch, containsKey, isEmpty, keyIterator, keySpliterator, keyStream, keyStreamParallel, removeUnchecked, tryRemove
-
Method Details
-
clear
public void clear()Description copied from class:FastHashBaseRemoves all the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
clearin interfaceJenaMapSetCommon<K>- Overrides:
clearin classFastHashBase<K>
-
tryPut
Description copied from interface:JenaMapTry to put a key-value pair into the map. If the key is already present, the value is updated. -
put
Description copied from interface:JenaMapPut a key-value pair into the map. If the key is already present, the value is updated. -
putAndGetIndex
Description copied from interface:JenaMapIndexedPut a key-value pair and return the index of the affected entry. If the key is already present, its value is updated and the existing index is returned.- Specified by:
putAndGetIndexin interfaceJenaMapIndexed<K,V> - Parameters:
key- the key to put. (nullis not allowed)value- the value to put. (nullis not allowed)- Returns:
- the index of the entry holding
key
-
getValueAt
Returns the value at the given index. Array bounds are not checked. The caller must ensure the index is valid and corresponds to a non-null key.- Specified by:
getValueAtin interfaceJenaMapIndexed<K,V> - Parameters:
i- index- Returns:
- value
-
get
Description copied from interface:JenaMapGet the value associated with the provided key. -
getOrDefault
Description copied from interface:JenaMapGet the value associated with the provided key, or a default value if the key is not present.- Specified by:
getOrDefaultin interfaceJenaMap<K,V> - Parameters:
key- the key to look updefaultValue- the default value to return if the key is not present- Returns:
- the value associated with the key, or the default value if the key is not present
-
computeIfAbsent
Description copied from interface:JenaMapCompute a value for a key if the key is not present. The value is automatically put into the map.- Specified by:
computeIfAbsentin interfaceJenaMap<K,V> - Parameters:
key- the key whose value is to retrieved or computedabsentValueSupplier- the function to compute a value for the key, if the key is not present- Returns:
- the value associated with the key, or the value computed by the function if the key is not present
-
compute
Description copied from interface:JenaMapCompute a value for a key.- Specified by:
computein interfaceJenaMap<K,V> - Parameters:
key- the key to compute a value forvalueProcessor- the function to compute a value for the key. The function is passed the current value associated with the key, or null if the key is not present. The function should return the new value to associate with the key, or null if the key should be removed from the map.
-
valueIterator
Description copied from interface:JenaMapGet an iterator over the values in the map.- Specified by:
valueIteratorin interfaceJenaMap<K,V> - Returns:
- an iterator over the values in the map
-
valueSpliterator
Description copied from interface:JenaMapGet a spliterator over the values in the map.- Specified by:
valueSpliteratorin interfaceJenaMap<K,V> - Returns:
- a spliterator over the values in the map
-