Top Description Fields Constructors Methods
com.carrotsearch.sizeof

pack-priv final Class IdentityHashSet<KType>

extends Object
implements Iterable<KType>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.util.*

An identity hash set implemented using open addressing. No null keys are allowed.

Field Summary

Modifier and TypeField and Description
public int
assigned

Cached number of assigned slots.

public static final float
DEFAULT_LOAD_FACTOR

Default load factor.

public Object[]
keys

All of set entries.

public final float
loadFactor

The load factor for this set (fraction of allocated or deleted slots before the buffers must be rehashed or reallocated).

public static final int
MIN_CAPACITY

Minimum capacity for the set.

private int
resizeThreshold

Cached capacity threshold at which we must resize the buffers.

Constructor Summary

AccessConstructor and Description
public
IdentityHashSet()

Creates a hash set with the default capacity of 16.

public
IdentityHashSet(int initialCapacity)

Creates a hash set with the given capacity, load factor of 0.75.

public
IdentityHashSet(int initialCapacity, float loadFactor)

Creates a hash set with the given capacity and load factor.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(KType e)

Adds a reference to the set.

private void
allocateBuffers(int
New capacity (must be a power of two).
capacity
)

Allocate internal buffers for a given capacity.

public void
public boolean
contains(KType e)

Checks if the set contains a given ref.

private void
expandAndRehash()

Expand the internal storage buffers (capacity) or rehash current keys and values if there are a lot of deleted slots.

public boolean
public Iterator<KType>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
protected int
nextCapacity(int current)

Return the next possible capacity, counting from the current buffers' size.

private static int
rehash(Object o)

Rehash via MurmurHash.

protected int
roundCapacity(int requestedCapacity)

Round the capacity to the next allowed value.

public int
size()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

assignedback to summary
public int assigned

Cached number of assigned slots.

DEFAULT_LOAD_FACTORback to summary
public static final float DEFAULT_LOAD_FACTOR

Default load factor.

keysback to summary
public Object[] keys

All of set entries. Always of power of two length.

loadFactorback to summary
public final float loadFactor

The load factor for this set (fraction of allocated or deleted slots before the buffers must be rehashed or reallocated).

MIN_CAPACITYback to summary
public static final int MIN_CAPACITY

Minimum capacity for the set.

resizeThresholdback to summary
private int resizeThreshold

Cached capacity threshold at which we must resize the buffers.

Constructor Detail

IdentityHashSetback to summary
public IdentityHashSet()

Creates a hash set with the default capacity of 16. load factor of 0.75. `

IdentityHashSetback to summary
public IdentityHashSet(int initialCapacity)

Creates a hash set with the given capacity, load factor of 0.75.

IdentityHashSetback to summary
public IdentityHashSet(int initialCapacity, float loadFactor)

Creates a hash set with the given capacity and load factor.

Method Detail

addback to summary
public boolean add(KType e)

Adds a reference to the set. Null keys are not allowed.

allocateBuffersback to summary
private void allocateBuffers(int capacity)

Allocate internal buffers for a given capacity.

Parameters
capacity:int

New capacity (must be a power of two).

clearback to summary
public void clear()
containsback to summary
public boolean contains(KType e)

Checks if the set contains a given ref.

expandAndRehashback to summary
private void expandAndRehash()

Expand the internal storage buffers (capacity) or rehash current keys and values if there are a lot of deleted slots.

isEmptyback to summary
public boolean isEmpty()
iteratorback to summary
public Iterator<KType> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<KType>

an Iterator.

Annotations
@Override
nextCapacityback to summary
protected int nextCapacity(int current)

Return the next possible capacity, counting from the current buffers' size.

rehashback to summary
private static int rehash(Object o)

Rehash via MurmurHash.

roundCapacityback to summary
protected int roundCapacity(int requestedCapacity)

Round the capacity to the next allowed value.

sizeback to summary
public int size()