T
- type of values stored in the Set
public class ObjectHashSet<T>
extends java.util.AbstractSet<T>
implements java.io.Serializable
Not Threadsafe.
This HashSet caches its iterator object by default, so nested iteration is not supported. You can override this behaviour at construction by indicating that the iterator should not be cached.
ObjectHashSet.ObjectIterator
,
Set
,
Serialized FormModifier and Type | Class and Description |
---|---|
class |
ObjectHashSet.ObjectIterator |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INITIAL_CAPACITY
The initial capacity used when none is specified in the constructor.
|
Constructor and Description |
---|
ObjectHashSet()
Construct a hash set with
DEFAULT_INITIAL_CAPACITY , Hashing.DEFAULT_LOAD_FACTOR ,
and iterator caching support. |
ObjectHashSet(int proposedCapacity)
Construct a hash set with a proposed initial capacity,
Hashing.DEFAULT_LOAD_FACTOR ,
and iterator caching support. |
ObjectHashSet(int proposedCapacity,
float loadFactor)
Construct a hash set with a proposed initial capacity, load factor, and iterator caching support.
|
ObjectHashSet(int proposedCapacity,
float loadFactor,
boolean shouldAvoidAllocation)
Construct a hash set with a proposed initial capacity, load factor, and indicated iterator caching support.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T value) |
boolean |
addAll(java.util.Collection<? extends T> coll) |
boolean |
addAll(ObjectHashSet<T> coll)
Alias for
addAll(Collection) for the specialized case when adding another ObjectHashSet,
avoids boxing and allocations |
int |
capacity()
Get the total capacity for the set to which the load factor with be a fraction of.
|
void |
clear() |
void |
compact()
Compact the backing arrays by rehashing with a capacity just larger than current size
and giving consideration to the load factor.
|
boolean |
contains(java.lang.Object value) |
boolean |
containsAll(java.util.Collection<?> coll) |
void |
copy(ObjectHashSet<T> that) |
ObjectHashSet<T> |
difference(ObjectHashSet<T> other)
Fast Path set difference for comparison with another ObjectHashSet.
|
boolean |
equals(java.lang.Object other) |
int |
hashCode() |
boolean |
isEmpty() |
ObjectHashSet.ObjectIterator |
iterator() |
float |
loadFactor()
Get the load factor beyond which the set will increase size.
|
boolean |
remove(java.lang.Object value) |
boolean |
removeAll(java.util.Collection<?> coll) |
boolean |
removeAll(ObjectHashSet<T> coll)
Alias for
removeAll(Collection) for the specialized case when removing another ObjectHashSet,
avoids boxing and allocations |
void |
resizeNotifier(java.util.function.IntConsumer resizeNotifier)
Add a Consumer that will be called when the collection is resized.
|
int |
resizeThreshold()
Get the actual threshold which when reached the map will resize.
|
int |
size() |
java.lang.Object[] |
toArray() |
<T1> T1[] |
toArray(T1[] into) |
java.lang.String |
toString() |
public static final int DEFAULT_INITIAL_CAPACITY
public ObjectHashSet()
DEFAULT_INITIAL_CAPACITY
, Hashing.DEFAULT_LOAD_FACTOR
,
and iterator caching support.public ObjectHashSet(int proposedCapacity)
Hashing.DEFAULT_LOAD_FACTOR
,
and iterator caching support.proposedCapacity
- for the initial capacity of the set.public ObjectHashSet(int proposedCapacity, float loadFactor)
proposedCapacity
- for the initial capacity of the set.loadFactor
- to be used for resizing.public ObjectHashSet(int proposedCapacity, float loadFactor, boolean shouldAvoidAllocation)
proposedCapacity
- for the initial capacity of the set.loadFactor
- to be used for resizing.shouldAvoidAllocation
- should the iterator be cached to avoid further allocation.public float loadFactor()
public int capacity()
public int resizeThreshold()
public void resizeNotifier(java.util.function.IntConsumer resizeNotifier)
resizeNotifier
- IntConsumer containing the new resizeThresholdpublic boolean add(T value)
add
in interface java.util.Collection<T>
add
in interface java.util.Set<T>
add
in class java.util.AbstractCollection<T>
value
- the value to addjava.lang.NullPointerException
- if the value is nullpublic boolean remove(java.lang.Object value)
public void compact()
public boolean contains(java.lang.Object value)
public int size()
public boolean isEmpty()
public void clear()
public boolean containsAll(java.util.Collection<?> coll)
public boolean addAll(java.util.Collection<? extends T> coll)
public boolean addAll(ObjectHashSet<T> coll)
addAll(Collection)
for the specialized case when adding another ObjectHashSet,
avoids boxing and allocationscoll
- containing the values to be added.true
if this set changed as a result of the callpublic ObjectHashSet<T> difference(ObjectHashSet<T> other)
NB: garbage free in the identical case, allocates otherwise.
other
- the other set to subtractpublic boolean removeAll(java.util.Collection<?> coll)
public boolean removeAll(ObjectHashSet<T> coll)
removeAll(Collection)
for the specialized case when removing another ObjectHashSet,
avoids boxing and allocationscoll
- containing the values to be removed.true
if this set changed as a result of the callpublic ObjectHashSet.ObjectIterator iterator()
public void copy(ObjectHashSet<T> that)
public java.lang.String toString()
toString
in class java.util.AbstractCollection<T>
public <T1> T1[] toArray(T1[] into)
public java.lang.Object[] toArray()
public boolean equals(java.lang.Object other)
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.