public final class IntHashSet
extends java.lang.Object
implements java.util.Set<java.lang.Integer>
By storing elements as int primitives this significantly reduces memory consumption compared with Java's builtin
HashSet<Integer>. It implements Set<Integer> for convenience, but calling
functionality via those methods can add boxing overhead to your usage.
Not Threadsafe.
This HashSet caches its iterator object, so nested iteration is not supported.
IntIterator,
Set| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY
The initial capacity used when none is specified in the constructor.
|
static float |
DEFAULT_LOAD_FACTOR
The load factor used when none is specified in the constructor.
|
| Constructor and Description |
|---|
IntHashSet(int missingValue) |
IntHashSet(int proposedCapacity,
int missingValue) |
IntHashSet(int initialCapacity,
int missingValue,
float loadFactor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int value)
Primitive specialised overload of {this#add(Integer)}
|
boolean |
add(java.lang.Integer value) |
boolean |
addAll(java.util.Collection<? extends java.lang.Integer> coll) |
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(int value) |
boolean |
contains(java.lang.Object value) |
boolean |
containsAll(java.util.Collection<?> coll) |
boolean |
containsAll(IntHashSet other)
IntHashSet specialised variant of {this#containsAll(Collection)}.
|
void |
copy(IntHashSet that) |
IntHashSet |
difference(IntHashSet other)
Fast Path set difference for comparison with another IntHashSet.
|
boolean |
equals(java.lang.Object other) |
int |
hashCode() |
boolean |
isEmpty() |
IntIterator |
iterator() |
float |
loadFactor()
Get the load factor beyond which the set will increase size.
|
int |
missingValue()
The value to be used as a null marker in the set.
|
boolean |
remove(int value)
An int specialised version of {this#remove(Object)}.
|
boolean |
remove(java.lang.Object value) |
boolean |
removeAll(java.util.Collection<?> coll) |
boolean |
retainAll(java.util.Collection<?> coll) |
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] into) |
java.lang.String |
toString() |
public static final float DEFAULT_LOAD_FACTOR
public static final int DEFAULT_INITIAL_CAPACITY
public IntHashSet(int missingValue)
public IntHashSet(int proposedCapacity,
int missingValue)
public IntHashSet(int initialCapacity,
int missingValue,
float loadFactor)
public int missingValue()
public boolean add(java.lang.Integer value)
add in interface java.util.Collection<java.lang.Integer>add in interface java.util.Set<java.lang.Integer>public boolean add(int value)
value - the value to addpublic boolean remove(java.lang.Object value)
remove in interface java.util.Collection<java.lang.Integer>remove in interface java.util.Set<java.lang.Integer>public boolean remove(int value)
value - the value to removepublic void compact()
public boolean contains(java.lang.Object value)
contains in interface java.util.Collection<java.lang.Integer>contains in interface java.util.Set<java.lang.Integer>public boolean contains(int value)
public int size()
size in interface java.util.Collection<java.lang.Integer>size in interface java.util.Set<java.lang.Integer>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Integer>isEmpty in interface java.util.Set<java.lang.Integer>public float loadFactor()
public int capacity()
public void clear()
clear in interface java.util.Collection<java.lang.Integer>clear in interface java.util.Set<java.lang.Integer>public boolean addAll(java.util.Collection<? extends java.lang.Integer> coll)
addAll in interface java.util.Collection<java.lang.Integer>addAll in interface java.util.Set<java.lang.Integer>public boolean containsAll(java.util.Collection<?> coll)
containsAll in interface java.util.Collection<java.lang.Integer>containsAll in interface java.util.Set<java.lang.Integer>public boolean containsAll(IntHashSet other)
other - int hash set to compare against.public IntHashSet difference(IntHashSet other)
NB: garbage free in the identical case, allocates otherwise.
other - the other set to subtractpublic boolean removeAll(java.util.Collection<?> coll)
removeAll in interface java.util.Collection<java.lang.Integer>removeAll in interface java.util.Set<java.lang.Integer>public IntIterator iterator()
iterator in interface java.lang.Iterable<java.lang.Integer>iterator in interface java.util.Collection<java.lang.Integer>iterator in interface java.util.Set<java.lang.Integer>public void copy(IntHashSet that)
public java.lang.String toString()
toString in class java.lang.Objectpublic <T> T[] toArray(T[] into)
toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.Set<java.lang.Integer>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.Set<java.lang.Integer>public boolean equals(java.lang.Object other)
equals in interface java.util.Collection<java.lang.Integer>equals in interface java.util.Set<java.lang.Integer>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Collection<java.lang.Integer>hashCode in interface java.util.Set<java.lang.Integer>hashCode in class java.lang.Objectpublic boolean retainAll(java.util.Collection<?> coll)
retainAll in interface java.util.Collection<java.lang.Integer>retainAll in interface java.util.Set<java.lang.Integer>Copyright © 2014 - 2016 Real Logic Ltd. All Rights Reserved.