java.lang.Object
org.apache.jena.mem2.collection.FastHashBase<K>
org.apache.jena.mem2.collection.FastHashSet<K>
- All Implemented Interfaces:
JenaMapSetCommon<K>
,JenaSet<K>
,JenaSetHashOptimized<K>
- Direct Known Subclasses:
FastHashedTripleBunch
Set which grows, if needed but never shrinks.
This set does not guarantee any order. Although due to the way it is implemented the elements have a certain order.
This set does not allow null values.
This set 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
HashSet
Iterating over this set not get much faster again after removing elements because the set is not compacted.-
Method Summary
Modifier and TypeMethodDescriptionint
addAndGetIndex
(K value) Add and get the index of the added element.int
addAndGetIndex
(K value, int hashCode) Add and get the index of the added element.void
addUnchecked
(K key) Add the key to the set without checking if it is already present.void
addUnchecked
(K value, int hashCode) getKeyAt
(int i) Gets the key at the given index.boolean
Add the key to the set if it is not already present.boolean
Methods inherited from class org.apache.jena.mem2.collection.FastHashBase
anyMatch, anyMatchRandomOrder, clear, 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.JenaMapSetCommon
anyMatch, clear, containsKey, isEmpty, keyIterator, keySpliterator, keyStream, keyStreamParallel, removeUnchecked, size, tryRemove
Methods inherited from interface org.apache.jena.mem2.collection.JenaSetHashOptimized
removeUnchecked, tryRemove
-
Method Details
-
tryAdd
Description copied from interface:JenaSet
Add the key to the set if it is not already present. -
tryAdd
- Specified by:
tryAdd
in interfaceJenaSetHashOptimized<K>
-
addAndGetIndex
Add and get the index of the added element.- Parameters:
value
- the value to add- Returns:
- the index of the added element or the inverse (~) index of the existing element
-
addAndGetIndex
Add and get the index of the added element.- Parameters:
value
- the value to addhashCode
- the hash code of the value. This is a performance optimization.- Returns:
- the index of the added element or the inverse (~) index of the existing element
-
addUnchecked
Description copied from interface:JenaSet
Add the key to the set without checking if it is already present. Attention: This method must only be used if it is guaranteed that the key is not already present.- Specified by:
addUnchecked
in interfaceJenaSet<K>
- Parameters:
key
- the key to add
-
addUnchecked
- Specified by:
addUnchecked
in interfaceJenaSetHashOptimized<K>
-
getKeyAt
Gets the key at the given index.- Parameters:
i
- the index- Returns:
- the key at the given index
-