java.lang.Object
org.apache.jena.mem2.collection.FastHashBase<K>
org.apache.jena.mem2.collection.FastHashMap<K,V>
- All Implemented Interfaces:
JenaMap<K,
,V> JenaMapSetCommon<K>
- Direct Known Subclasses:
FastHashedBunchMap
Map which grows, if needed but never shrinks.
This map does not guarantee any order. Although due to the way it is implemented the elements have a certain order.
This map does not allow null keys.
This map is not thread safe.
It´s purpose is to support fast add, remove, contains and stream / iterate operations.
Only remove operations are not as fast as in
HashMap
Iterating over this map does not get much faster again after removing elements because the map is not compacted.-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all the elements from this collection (optional operation).void
compute
(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.void
Put a key-value pair into the map.boolean
Try 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.mem2.collection.FastHashBase
anyMatch, anyMatchRandomOrder, containsKey, isEmpty, keyIterator, keySpliterator, removeAndGetIndex, removeAndGetIndex, removeUnchecked, removeUnchecked, size, tryRemove, tryRemove
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.jena.mem2.collection.JenaMap
valueStream, valueStreamParallel
Methods inherited from interface org.apache.jena.mem2.collection.JenaMapSetCommon
anyMatch, containsKey, isEmpty, keyIterator, keySpliterator, keyStream, keyStreamParallel, removeUnchecked, size, tryRemove
-
Method Details
-
clear
public void clear()Description copied from class:FastHashBase
Removes all the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
clear
in interfaceJenaMapSetCommon<K>
- Overrides:
clear
in classFastHashBase<K>
-
tryPut
Description copied from interface:JenaMap
Try to put a key-value pair into the map. If the key is already present, the value is updated. -
put
Description copied from interface:JenaMap
Put a key-value pair into the map. If the key is already present, the value is updated. -
getValueAt
Returns the value at the given index.- Parameters:
i
- index- Returns:
- value
-
get
Description copied from interface:JenaMap
Get the value associated with the provided key. -
getOrDefault
Description copied from interface:JenaMap
Get the value associated with the provided key, or a default value if the key is not present.- Specified by:
getOrDefault
in 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:JenaMap
Compute a value for a key if the key is not present. The value is automatically put into the map.- Specified by:
computeIfAbsent
in 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:JenaMap
Compute a value for a key.- Specified by:
compute
in 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:JenaMap
Get an iterator over the values in the map.- Specified by:
valueIterator
in interfaceJenaMap<K,
V> - Returns:
- an iterator over the values in the map
-
valueSpliterator
Description copied from interface:JenaMap
Get a spliterator over the values in the map.- Specified by:
valueSpliterator
in interfaceJenaMap<K,
V> - Returns:
- a spliterator over the values in the map
-