@Generated(value="Autogenerated by OpenJAX CodeGen Template (0.2.5)", date="2020-05-23") public class HashIntSet extends HashPrimitiveSet implements IntSet
IntSet
implementing
open-addressing
(closed hashing) with linear-probing for collision resolution algorithm,
with allocation-free operation in steady state when expanded.
This class replicates the API of the HashSet
class by
defining synonymous methods for a set of int
values instead of
Object references.
Constructor and Description |
---|
HashIntSet()
Creates an empty
HashIntSet with the default initial capacity
(16) and the default load factor (0.55). |
HashIntSet(Collection<Integer> c)
Creates a new
HashIntSet with the same values as the specified
collection. |
HashIntSet(int initialCapacity)
Creates an empty
HashIntSet with the specified initial capacity and
the default load factor (0.55). |
HashIntSet(IntCollection c)
Creates a new
HashIntSet with the same values as the specified
collection. |
HashIntSet(int initialCapacity,
float loadFactor)
Creates an empty
HashIntSet with the specified initial capacity and
load factor. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(int value)
Adds the specified value to this set if it is not already present.
|
boolean |
addAll(Collection<Integer> c)
Adds all of the values in the specified collection to this set if they're
not already present.
|
boolean |
addAll(HashIntSet s)
Adds all of the values in the specified set to this set if they're not
already present.
|
boolean |
addAll(IntCollection c)
Adds all of the values in the specified collection to this set if they're
not already present.
|
void |
clear()
Removes all of the values from this set.
|
HashIntSet |
clone() |
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)
Returns
true if this set contains the specified value. |
boolean |
containsAll(Collection<Integer> c)
Returns
true if this set contains all of the values of the
specified collection. |
boolean |
containsAll(IntCollection c)
Returns
true if this set contains all of the values of the
specified collection. |
boolean |
equals(Object obj)
Compares the specified object with this set for equality.
|
int |
hashCode()
Returns the hash code value for this set.
|
boolean |
isEmpty()
Returns
true if this set contains no values. |
IntIterator |
iterator()
Returns an iterator over the values in this set.
|
IntStream |
parallelStream()
Returns a possibly parallel
IntStream over the values in this
collection. |
boolean |
remove(int value)
Removes the specified value from this set if it is present.
|
boolean |
removeAll(Collection<Integer> c)
Removes from this set all of its values that are contained in the specified
collection.
|
boolean |
removeAll(HashIntSet s)
Removes from this set all of its values that are contained in the specified
set.
|
boolean |
removeAll(int... a)
Removes all of this collection's values that are also contained in the
specified vararg array.
|
boolean |
removeAll(IntCollection c)
Removes from this set all of its values that are contained in the specified
collection.
|
boolean |
retainAll(Collection<Integer> c)
Retains only the values in this set that are contained in the specified
collection.
|
boolean |
retainAll(IntCollection c)
Retains only the values in this set that are contained in the specified
collection.
|
int |
size()
Returns the number of values in this set (its cardinality).
|
Spliterator.OfInt |
spliterator()
Creates a
Spliterator.OfInt over the elements in this set. |
IntStream |
stream()
Returns a sequential
IntStream over the values in this collection. |
int[] |
toArray(int[] a)
Returns an array containing all of the values in this collection in proper
sequence (from first to last value).
|
Integer[] |
toArray(Integer[] a)
Returns an array containing all of the values in this collection in proper
sequence (from first to last value).
|
String |
toString() |
findNextPositivePowerOfTwo, hash, nextIndex
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, removeIf, toArray
public HashIntSet()
HashIntSet
with the default initial capacity
(16) and the default load factor (0.55).public HashIntSet(int initialCapacity, float loadFactor)
HashIntSet
with the specified initial capacity and
load factor.initialCapacity
- The initial capacity.loadFactor
- The load factor.IllegalArgumentException
- If the initial capacity is negative or the
load factor less than .1
or greater than .9
.public HashIntSet(int initialCapacity)
HashIntSet
with the specified initial capacity and
the default load factor (0.55).initialCapacity
- The initial capacity.IllegalArgumentException
- If the initial capacity is negative.public HashIntSet(IntCollection c)
HashIntSet
with the same values as the specified
collection. The HashIntSet
is created with default load factor
(0.55) and an initial capacity sufficient to hold the mappings in the
specified collection.c
- The collection whose values are to be added to this set.NullPointerException
- If the specified set is null.public HashIntSet(Collection<Integer> c)
HashIntSet
with the same values as the specified
collection. The HashIntSet
is created with default load factor
(0.55) and an initial capacity sufficient to hold the mappings in the
specified collection.c
- The collection whose values are to be added to this set.NullPointerException
- If the specified set is null.public boolean add(int value)
IntSet
value
to this set if the set
contains no value value2
such that value == value2
. If this
set already contains the value, the call leaves the set unchanged and
returns false
. In combination with the restriction on constructors,
this ensures that sets never contain duplicate values.add
in interface IntCollection
add
in interface IntSet
value
- Value to be added to this set.true
if this set did not already contain the specified
value.public boolean addAll(IntCollection c)
IntSet
addAll
operation effectively modifies this set so that its value is
the union of the two sets. The behavior of this operation is
undefined if the specified collection is modified while the operation is in
progress.addAll
in interface IntCollection
addAll
in interface IntSet
c
- Collection containing values to be added to this set.true
if this set changed as a result of the call.IntSet.addAll(Collection)
,
IntSet.add(int)
public boolean addAll(Collection<Integer> c)
IntSet
addAll
operation effectively modifies this set so that its value is
the union of the two sets. The behavior of this operation is
undefined if the specified collection is modified while the operation is in
progress.addAll
in interface IntCollection
addAll
in interface IntSet
c
- Collection containing values to be added to this set.true
if this set changed as a result of the call.IntSet.addAll(IntCollection)
,
IntSet.add(int)
public boolean addAll(HashIntSet s)
addAll
operation effectively modifies this set
so that its value is the union of the two sets. The behavior of this
operation is undefined if the specified collection is modified while the
operation is in progress.s
- Set containing values to be added to this set.true
if this set changed as a result of the call.NullPointerException
- If the specified set is null.addAll(IntCollection)
,
add(int)
public boolean contains(int value)
IntSet
true
if this set contains the specified value. More
formally, returns true
if and only if this set contains a value
v
such that Objects.equals(value, v)
.contains
in interface IntCollection
contains
in interface IntSet
value
- Value whose presence in this set is to be tested.true
if this set contains the specified value.public boolean containsAll(IntCollection c)
IntSet
true
if this set contains all of the values of the
specified collection. If the specified collection is also a set, this
method returns true
if it is a subset of this set.containsAll
in interface IntCollection
containsAll
in interface IntSet
c
- Collection to be checked for containment in this set.true
if this set contains all of the values of the
specified collection.IntSet.containsAll(Collection)
,
IntSet.contains(int)
public boolean containsAll(Collection<Integer> c)
IntSet
true
if this set contains all of the values of the
specified collection. If the specified collection is also a set, this
method returns true
if it is a subset of this set.containsAll
in interface IntCollection
containsAll
in interface IntSet
c
- Collection to be checked for containment in this set.true
if this set contains all of the values of the
specified collection.IntSet.containsAll(IntCollection)
,
IntSet.contains(int)
public boolean remove(int value)
IntSet
v
such that Objects.equals(value, v)
, if
this set contains such an value. Returns true
if this set contained
the value (or equivalently, if this set changed as a result of the call).
(This set will not contain the value once the call returns).remove
in interface IntCollection
remove
in interface IntSet
value
- Value to be removed from this set, if present.true
if this set contained the specified value.public boolean removeAll(int... a)
IntCollection
removeAll
in interface IntCollection
a
- Array containing values to be removed from this collection.true
if this collection changed as a result of the call.IntCollection.remove(int)
,
IntCollection.contains(int)
public boolean removeAll(IntCollection c)
IntSet
removeAll
in interface IntCollection
removeAll
in interface IntSet
c
- Collection containing values to be removed from this set.true
if this set changed as a result of the call.IntSet.removeAll(Collection)
,
IntSet.remove(int)
,
IntSet.contains(int)
public boolean removeAll(Collection<Integer> c)
IntSet
removeAll
in interface IntCollection
removeAll
in interface IntSet
c
- Collection containing values to be removed from this set.true
if this set changed as a result of the call.IntSet.removeAll(IntCollection)
,
IntSet.remove(int)
,
IntSet.contains(int)
public boolean removeAll(HashIntSet s)
s
- Set containing values to be removed from this set.true
if this set changed as a result of the call.NullPointerException
- If the specified collection is null.removeAll(IntCollection)
,
remove(int)
,
contains(int)
public boolean retainAll(IntCollection c)
IntSet
retainAll
in interface IntCollection
retainAll
in interface IntSet
c
- Collection containing values to be retained in this set.true
if this set changed as a result of the call.IntSet.retainAll(Collection)
,
IntSet.remove(int)
,
IntSet.contains(int)
public boolean retainAll(Collection<Integer> c)
IntSet
retainAll
in interface IntCollection
retainAll
in interface IntSet
c
- Collection containing values to be retained in this set.true
if this set changed as a result of the call.IntSet.retainAll(IntCollection)
,
IntSet.remove(int)
,
IntSet.contains(int)
public void clear()
IntSet
clear
in interface IntSet
clear
in interface PrimitiveCollection
public int size()
IntSet
Integer.MAX_VALUE
values, returns
Integer.MAX_VALUE
.size
in interface IntSet
size
in interface PrimitiveCollection
public boolean isEmpty()
IntSet
true
if this set contains no values.isEmpty
in interface IntSet
isEmpty
in interface PrimitiveCollection
true
if this set contains no values.public int[] toArray(int[] a)
IntCollection
If the collection fits in the specified array with room to spare (i.e., the
array has more values than the collection), the value in the array
immediately following the end of the collection is set to 0
. (This
is useful in determining the length of the collection only if the
caller knows that the collection does not contain any 0
values).
toArray
in interface IntCollection
a
- The array into which the values of the collection are to be
stored. If the array is not big enough to store the values, a new
array is allocated.public Integer[] toArray(Integer[] a)
IntCollection
If the collection fits in the specified array with room to spare (i.e., the array has more values than the collection), the value in the array immediately following the end of the collection is set to null.
toArray
in interface IntCollection
a
- The array into which the values of the collection are to be
stored. If the array is not big enough to store the values, a new
array is allocated.public IntIterator iterator()
IntSet
iterator
in interface IntIterable
iterator
in interface IntSet
public Spliterator.OfInt spliterator()
IntSet
Spliterator.OfInt
over the elements in this set.
The Spliterator.OfInt
reports Spliterator.DISTINCT
.
spliterator
in interface IntCollection
spliterator
in interface IntSet
Spliterator.OfInt
over the elements in this set.Spliterator.OfInt
public IntStream stream()
IntCollection
IntStream
over the values in this collection.stream
in interface IntCollection
IntStream
over the values in this collection.public IntStream parallelStream()
IntCollection
IntStream
over the values in this
collection.parallelStream
in interface IntCollection
IntStream
over the values in this
collection.public void compact()
public HashIntSet clone()
public boolean equals(Object obj)
IntSet
true
if the specified object is also a set, the two sets have the
same size, and every member of the specified set is contained in this set
(or equivalently, every member of this set is contained in the specified
set). This definition ensures that the equals method works properly across
different implementations of the set interface.equals
in interface IntSet
equals
in interface PrimitiveCollection
equals
in class Object
obj
- Object to be compared for equality with this set.true
if the specified object is equal to this set.Object.equals(Object)
,
IntSet.equals(Object)
,
IntList.equals(Object)
public int hashCode()
IntSet
s1 == s2
implies that s1.hashCode() == s2.hashCode()
for
any two sets s1
and s2
, as required by the general contract
of Object.hashCode()
.hashCode
in interface IntSet
hashCode
in interface PrimitiveCollection
hashCode
in class Object
Object.equals(Object)
,
IntSet.equals(Object)
Copyright © 2020 LibJ. All rights reserved.