@Generated(value="Autogenerated by OpenJAX CodeGen Template (0.2.5)", date="2020-05-23") public class HashDoubleSet extends HashPrimitiveSet implements DoubleSet
DoubleSet
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 double
values instead of
Object references.
Constructor and Description |
---|
HashDoubleSet()
Creates an empty
HashDoubleSet with the default initial capacity
(16) and the default load factor (0.55). |
HashDoubleSet(Collection<Double> c)
Creates a new
HashDoubleSet with the same values as the specified
collection. |
HashDoubleSet(DoubleCollection c)
Creates a new
HashDoubleSet with the same values as the specified
collection. |
HashDoubleSet(int initialCapacity)
Creates an empty
HashDoubleSet with the specified initial capacity and
the default load factor (0.55). |
HashDoubleSet(int initialCapacity,
float loadFactor)
Creates an empty
HashDoubleSet with the specified initial capacity and
load factor. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(double value)
Adds the specified value to this set if it is not already present.
|
boolean |
addAll(Collection<Double> c)
Adds all of the values in the specified collection to this set if they're
not already present.
|
boolean |
addAll(DoubleCollection c)
Adds all of the values in the specified collection to this set if they're
not already present.
|
boolean |
addAll(HashDoubleSet s)
Adds all of the values in the specified set to this set if they're not
already present.
|
void |
clear()
Removes all of the values from this set.
|
HashDoubleSet |
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(double value)
Returns
true if this set contains the specified value. |
boolean |
containsAll(Collection<Double> c)
Returns
true if this set contains all of the values of the
specified collection. |
boolean |
containsAll(DoubleCollection 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. |
DoubleIterator |
iterator()
Returns an iterator over the values in this set.
|
DoubleStream |
parallelStream()
Returns a possibly parallel
DoubleStream over the values in this
collection. |
boolean |
remove(double value)
Removes the specified value from this set if it is present.
|
boolean |
removeAll(Collection<Double> c)
Removes from this set all of its values that are contained in the specified
collection.
|
boolean |
removeAll(double... a)
Removes all of this collection's values that are also contained in the
specified vararg array.
|
boolean |
removeAll(DoubleCollection c)
Removes from this set all of its values that are contained in the specified
collection.
|
boolean |
removeAll(HashDoubleSet s)
Removes from this set all of its values that are contained in the specified
set.
|
boolean |
retainAll(Collection<Double> c)
Retains only the values in this set that are contained in the specified
collection.
|
boolean |
retainAll(DoubleCollection 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.OfDouble |
spliterator()
Creates a
Spliterator.OfDouble over the elements in this set. |
DoubleStream |
stream()
Returns a sequential
DoubleStream over the values in this collection. |
double[] |
toArray(double[] a)
Returns an array containing all of the values in this collection in proper
sequence (from first to last value).
|
Double[] |
toArray(Double[] 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 HashDoubleSet()
HashDoubleSet
with the default initial capacity
(16) and the default load factor (0.55).public HashDoubleSet(int initialCapacity, float loadFactor)
HashDoubleSet
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 HashDoubleSet(int initialCapacity)
HashDoubleSet
with the specified initial capacity and
the default load factor (0.55).initialCapacity
- The initial capacity.IllegalArgumentException
- If the initial capacity is negative.public HashDoubleSet(DoubleCollection c)
HashDoubleSet
with the same values as the specified
collection. The HashDoubleSet
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 HashDoubleSet(Collection<Double> c)
HashDoubleSet
with the same values as the specified
collection. The HashDoubleSet
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(double value)
DoubleSet
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 DoubleCollection
add
in interface DoubleSet
value
- Value to be added to this set.true
if this set did not already contain the specified
value.public boolean addAll(DoubleCollection c)
DoubleSet
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 DoubleCollection
addAll
in interface DoubleSet
c
- Collection containing values to be added to this set.true
if this set changed as a result of the call.DoubleSet.addAll(Collection)
,
DoubleSet.add(double)
public boolean addAll(Collection<Double> c)
DoubleSet
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 DoubleCollection
addAll
in interface DoubleSet
c
- Collection containing values to be added to this set.true
if this set changed as a result of the call.DoubleSet.addAll(DoubleCollection)
,
DoubleSet.add(double)
public boolean addAll(HashDoubleSet 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(DoubleCollection)
,
add(double)
public boolean contains(double value)
DoubleSet
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 DoubleCollection
contains
in interface DoubleSet
value
- Value whose presence in this set is to be tested.true
if this set contains the specified value.public boolean containsAll(DoubleCollection c)
DoubleSet
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 DoubleCollection
containsAll
in interface DoubleSet
c
- Collection to be checked for containment in this set.true
if this set contains all of the values of the
specified collection.DoubleSet.containsAll(Collection)
,
DoubleSet.contains(double)
public boolean containsAll(Collection<Double> c)
DoubleSet
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 DoubleCollection
containsAll
in interface DoubleSet
c
- Collection to be checked for containment in this set.true
if this set contains all of the values of the
specified collection.DoubleSet.containsAll(DoubleCollection)
,
DoubleSet.contains(double)
public boolean remove(double value)
DoubleSet
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 DoubleCollection
remove
in interface DoubleSet
value
- Value to be removed from this set, if present.true
if this set contained the specified value.public boolean removeAll(double... a)
DoubleCollection
removeAll
in interface DoubleCollection
a
- Array containing values to be removed from this collection.true
if this collection changed as a result of the call.DoubleCollection.remove(double)
,
DoubleCollection.contains(double)
public boolean removeAll(DoubleCollection c)
DoubleSet
removeAll
in interface DoubleCollection
removeAll
in interface DoubleSet
c
- Collection containing values to be removed from this set.true
if this set changed as a result of the call.DoubleSet.removeAll(Collection)
,
DoubleSet.remove(double)
,
DoubleSet.contains(double)
public boolean removeAll(Collection<Double> c)
DoubleSet
removeAll
in interface DoubleCollection
removeAll
in interface DoubleSet
c
- Collection containing values to be removed from this set.true
if this set changed as a result of the call.DoubleSet.removeAll(DoubleCollection)
,
DoubleSet.remove(double)
,
DoubleSet.contains(double)
public boolean removeAll(HashDoubleSet 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(DoubleCollection)
,
remove(double)
,
contains(double)
public boolean retainAll(DoubleCollection c)
DoubleSet
retainAll
in interface DoubleCollection
retainAll
in interface DoubleSet
c
- Collection containing values to be retained in this set.true
if this set changed as a result of the call.DoubleSet.retainAll(Collection)
,
DoubleSet.remove(double)
,
DoubleSet.contains(double)
public boolean retainAll(Collection<Double> c)
DoubleSet
retainAll
in interface DoubleCollection
retainAll
in interface DoubleSet
c
- Collection containing values to be retained in this set.true
if this set changed as a result of the call.DoubleSet.retainAll(DoubleCollection)
,
DoubleSet.remove(double)
,
DoubleSet.contains(double)
public void clear()
DoubleSet
clear
in interface DoubleSet
clear
in interface PrimitiveCollection
public int size()
DoubleSet
Double.MAX_VALUE
values, returns
Double.MAX_VALUE
.size
in interface DoubleSet
size
in interface PrimitiveCollection
public boolean isEmpty()
DoubleSet
true
if this set contains no values.isEmpty
in interface DoubleSet
isEmpty
in interface PrimitiveCollection
true
if this set contains no values.public double[] toArray(double[] a)
DoubleCollection
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 DoubleCollection
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 Double[] toArray(Double[] a)
DoubleCollection
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 DoubleCollection
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 DoubleIterator iterator()
DoubleSet
iterator
in interface DoubleIterable
iterator
in interface DoubleSet
public Spliterator.OfDouble spliterator()
DoubleSet
Spliterator.OfDouble
over the elements in this set.
The Spliterator.OfDouble
reports Spliterator.DISTINCT
.
spliterator
in interface DoubleCollection
spliterator
in interface DoubleSet
Spliterator.OfDouble
over the elements in this set.Spliterator.OfDouble
public DoubleStream stream()
DoubleCollection
DoubleStream
over the values in this collection.stream
in interface DoubleCollection
DoubleStream
over the values in this collection.public DoubleStream parallelStream()
DoubleCollection
DoubleStream
over the values in this
collection.parallelStream
in interface DoubleCollection
DoubleStream
over the values in this
collection.public void compact()
public HashDoubleSet clone()
public boolean equals(Object obj)
DoubleSet
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 DoubleSet
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()
DoubleSet
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 DoubleSet
hashCode
in interface PrimitiveCollection
hashCode
in class Object
Object.equals(Object)
,
DoubleSet.equals(Object)
Copyright © 2020 LibJ. All rights reserved.