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 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.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
-