Class IdentityHashSet<KType>
java.lang.Object
com.carrotsearch.randomizedtesting.rules.IdentityHashSet<KType>
- All Implemented Interfaces:
Iterable<KType>
-
Field Summary
FieldsModifier and TypeFieldDescriptionintCached number of assigned slots.static final floatDefault load factor.Object[]All of set entries.final floatThe load factor for this set (fraction of allocated or deleted slots before the buffers must be rehashed or reallocated).static final intMinimum capacity for the set.private intCached capacity threshold at which we must resize the buffers. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a hash set with the default capacity of 16.IdentityHashSet(int initialCapacity) IdentityHashSet(int initialCapacity, float loadFactor) Creates a hash set with the given capacity and load factor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a reference to the set.private voidallocateBuffers(int capacity) Allocate internal buffers for a given capacity.voidclear()booleanChecks if the set contains a given ref.private voidExpand the internal storage buffers (capacity) or rehash current keys and values if there are a lot of deleted slots.booleanisEmpty()iterator()protected intnextCapacity(int current) Return the next possible capacity, counting from the current buffers' size.private static intRehash via MurmurHash.protected introundCapacity(int requestedCapacity) Round the capacity to the next allowed value.intsize()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_LOAD_FACTOR
public static final float DEFAULT_LOAD_FACTORDefault load factor.- See Also:
-
MIN_CAPACITY
public static final int MIN_CAPACITYMinimum capacity for the set.- See Also:
-
keys
All of set entries. Always of power of two length. -
assigned
public int assignedCached number of assigned slots. -
loadFactor
public final float loadFactorThe load factor for this set (fraction of allocated or deleted slots before the buffers must be rehashed or reallocated). -
resizeThreshold
private int resizeThresholdCached capacity threshold at which we must resize the buffers.
-
-
Constructor Details
-
IdentityHashSet
-
IdentityHashSet
-
IdentityHashSet
public IdentityHashSet(int initialCapacity, float loadFactor) Creates a hash set with the given capacity and load factor.
-
-
Method Details
-
add
Adds a reference to the set. Null keys are not allowed. -
contains
Checks if the set contains a given ref. -
rehash
Rehash via MurmurHash. -
expandAndRehash
private void expandAndRehash()Expand the internal storage buffers (capacity) or rehash current keys and values if there are a lot of deleted slots. -
allocateBuffers
private void allocateBuffers(int capacity) Allocate internal buffers for a given capacity.- Parameters:
capacity- New capacity (must be a power of two).
-
nextCapacity
protected int nextCapacity(int current) Return the next possible capacity, counting from the current buffers' size. -
roundCapacity
protected int roundCapacity(int requestedCapacity) Round the capacity to the next allowed value. -
clear
public void clear() -
size
public int size() -
isEmpty
public boolean isEmpty() -
iterator
-