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,TripleSet
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordEntry pairing a key with its index in the set. -
Method Summary
Modifier and TypeMethodDescriptionintaddAndGetIndex(K value) Add and get the index of the added element.intaddAndGetIndex(K value, int hashCode) Add and get the index of the added element.voidaddUnchecked(K key) Add the key to the set without checking if it is already present.voidaddUnchecked(K value, int hashCode) getKeyAt(int i) Gets the key at the given index.final ExtendedIterator<FastHashSet.IndexedKey<K>>Get an iterator over pairs of keys and their indices in the set.final Spliterator<FastHashSet.IndexedKey<K>>Get a spliterator over pairs of keys and their indices in the set.final Stream<FastHashSet.IndexedKey<K>>Get a stream over pairs of keys and their indices in the set.final Stream<FastHashSet.IndexedKey<K>>Get a parallel stream over pairs of keys and their indices in the set.booleanAdd the key to the set if it is not already present.booleanMethods inherited from class org.apache.jena.mem2.collection.FastHashBase
anyMatch, anyMatchRandomOrder, clear, containsKey, isEmpty, keyIterator, keySpliterator, removeAndGetIndex, 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.mem2.collection.JenaMapSetCommon
anyMatch, clear, containsKey, isEmpty, keyIterator, keySpliterator, keyStream, keyStreamParallel, removeUnchecked, size, tryRemoveMethods inherited from interface org.apache.jena.mem2.collection.JenaSetHashOptimized
removeUnchecked, tryRemove
-
Method Details
-
tryAdd
Description copied from interface:JenaSetAdd the key to the set if it is not already present. -
tryAdd
- Specified by:
tryAddin 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:JenaSetAdd 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:
addUncheckedin interfaceJenaSet<K>- Parameters:
key- the key to add
-
addUnchecked
- Specified by:
addUncheckedin interfaceJenaSetHashOptimized<K>
-
getKeyAt
Gets the key at the given index.- Parameters:
i- the index- Returns:
- the key at the given index
-
indexedKeyIterator
Get an iterator over pairs of keys and their indices in the set. The iterator is not thread safe.- Returns:
- an iterator over pairs of keys and their indices in the set
-
indexedKeySpliterator
Get a spliterator over pairs of keys and their indices in the set. The spliterator is not thread safe.- Returns:
- a spliterator over pairs of keys and their indices in the set
-
indexedKeyStream
Get a stream over pairs of keys and their indices in the set. The stream is not thread safe.- Returns:
- a stream over pairs of keys and their indices in the set
-
indexedKeyStreamParallel
Get a parallel stream over pairs of keys and their indices in the set. The stream is not thread safe.- Returns:
- a parallel stream over pairs of keys and their indices in the set
-