Package com.carrotsearch.hppc
Class ObjectIdentityHashSet<KType>
- java.lang.Object
-
- com.carrotsearch.hppc.ObjectHashSet<KType>
-
- com.carrotsearch.hppc.ObjectIdentityHashSet<KType>
-
- All Implemented Interfaces:
ObjectCollection<KType>
,ObjectContainer<KType>
,ObjectLookupContainer<KType>
,ObjectSet<KType>
,Preallocable
,java.lang.Cloneable
,java.lang.Iterable<ObjectCursor<KType>>
public class ObjectIdentityHashSet<KType> extends ObjectHashSet<KType>
A reference-equality (identity) hash set.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.carrotsearch.hppc.ObjectHashSet
ObjectHashSet.EntryIterator
-
-
Field Summary
-
Fields inherited from class com.carrotsearch.hppc.ObjectHashSet
assigned, hasEmptyKey, keyMixer, keys, loadFactor, mask, orderMixer, resizeAt
-
-
Constructor Summary
Constructors Constructor Description ObjectIdentityHashSet()
New instance with sane defaults.ObjectIdentityHashSet(int expectedElements)
New instance with sane defaults.ObjectIdentityHashSet(int expectedElements, double loadFactor)
New instance with sane defaults.ObjectIdentityHashSet(int expectedElements, double loadFactor, HashOrderMixingStrategy orderMixer)
New instance with the provided defaults.ObjectIdentityHashSet(ObjectContainer<? extends KType> container)
New instance copying elements from anotherObjectContainer
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
equals(java.lang.Object v1, java.lang.Object v2)
static <KType> ObjectIdentityHashSet<KType>
from(KType... elements)
Create a set from a variable number of arguments or an array ofKType
.protected int
hashKey(KType key)
Returns a hash code for the given key.int
removeAll(ObjectLookupContainer<? super KType> c)
Default implementation uses a predicate for removal.int
retainAll(ObjectLookupContainer<? super KType> c)
Default implementation uses a predicate for retaining.int
retainAll(ObjectPredicate<? super KType> predicate)
Default implementation redirects toObjectCollection.removeAll(ObjectPredicate)
and negates the predicate.<T> T[]
toArray(java.lang.Class<T> componentClass)
Copies all elements of this container to a dynamically created array of the given component type.java.lang.String
toString()
Convert the contents of this container to a human-friendly string.-
Methods inherited from class com.carrotsearch.hppc.ObjectHashSet
add, addAll, addAll, addAll, allocateBuffers, allocateThenInsertThenRehash, clear, clone, contains, ensureCapacity, equals, forEach, hashCode, indexExists, indexGet, indexInsert, indexOf, indexReplace, isEmpty, iterator, rehash, release, remove, removeAll, removeAll, shiftConflictingKeys, size, toArray, verifyLoadFactor, visualizeKeyDistribution
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.carrotsearch.hppc.ObjectCollection
removeAll, retainAll, retainAll
-
Methods inherited from interface com.carrotsearch.hppc.ObjectContainer
toArray
-
-
-
-
Constructor Detail
-
ObjectIdentityHashSet
public ObjectIdentityHashSet()
New instance with sane defaults.
-
ObjectIdentityHashSet
public ObjectIdentityHashSet(int expectedElements)
New instance with sane defaults.
-
ObjectIdentityHashSet
public ObjectIdentityHashSet(int expectedElements, double loadFactor)
New instance with sane defaults.
-
ObjectIdentityHashSet
public ObjectIdentityHashSet(int expectedElements, double loadFactor, HashOrderMixingStrategy orderMixer)
New instance with the provided defaults.- Parameters:
expectedElements
- The expected number of elements guaranteed not to cause a rehash (inclusive).loadFactor
- The load factor for internal buffers. Insane load factors (zero, full capacity) are rejected byObjectHashSet.verifyLoadFactor(double)
.orderMixer
- Hash key order mixing strategy. SeeHashOrderMixing
for predefined implementations. Use constant mixers only if you understand the potential consequences.
-
ObjectIdentityHashSet
public ObjectIdentityHashSet(ObjectContainer<? extends KType> container)
New instance copying elements from anotherObjectContainer
.
-
-
Method Detail
-
hashKey
protected int hashKey(KType key)
Description copied from class:ObjectHashSet
Returns a hash code for the given key. The default implementation mixes the hash of the key withObjectHashSet.keyMixer
to differentiate hash order of keys between hash containers. Helps alleviate problems resulting from linear conflict resolution in open addressing. The output from this function should evenly distribute keys across the entire integer range.- Overrides:
hashKey
in classObjectHashSet<KType>
-
equals
protected boolean equals(java.lang.Object v1, java.lang.Object v2)
-
from
@SafeVarargs public static <KType> ObjectIdentityHashSet<KType> from(KType... elements)
Create a set from a variable number of arguments or an array ofKType
. The elements are copied from the argument to the internal buffer.
-
removeAll
public int removeAll(ObjectLookupContainer<? super KType> c)
Default implementation uses a predicate for removal.- Specified by:
removeAll
in interfaceObjectCollection<KType>
- Returns:
- Returns the number of removed elements.
-
retainAll
public int retainAll(ObjectLookupContainer<? super KType> c)
Default implementation uses a predicate for retaining.- Specified by:
retainAll
in interfaceObjectCollection<KType>
- Returns:
- Returns the number of removed elements.
-
retainAll
public int retainAll(ObjectPredicate<? super KType> predicate)
Default implementation redirects toObjectCollection.removeAll(ObjectPredicate)
and negates the predicate.- Specified by:
retainAll
in interfaceObjectCollection<KType>
- Returns:
- Returns the number of removed elements.
-
toArray
public <T> T[] toArray(java.lang.Class<T> componentClass)
Description copied from interface:ObjectContainer
Copies all elements of this container to a dynamically created array of the given component type.- Specified by:
toArray
in interfaceObjectContainer<KType>
-
toString
public java.lang.String toString()
Convert the contents of this container to a human-friendly string.- Overrides:
toString
in classjava.lang.Object
-
-