Class DoubleHashSet
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractDoubleIterable
-
- org.eclipse.collections.impl.set.primitive.AbstractDoubleSet
-
- org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,MutableDoubleCollection
,DoubleIterable
,PrimitiveIterable
,DoubleSet
,MutableDoubleSet
public class DoubleHashSet extends AbstractDoubleSet implements MutableDoubleSet, java.io.Externalizable
This file was automatically generated from template file primitiveHashSet.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DoubleHashSet.ImmutableDoubleHashSet
private class
DoubleHashSet.InternalDoubleIterator
-
Field Summary
Fields Modifier and Type Field Description private static int
CACHE_LINE_SIZE
private boolean
copyOnWrite
private static int
DEFAULT_INITIAL_CAPACITY
private static double
EMPTY
private static int
INITIAL_LINEAR_PROBE
private static int
KEY_SIZE
private int
occupiedWithData
private int
occupiedWithSentinels
private static double
REMOVED
private static long
serialVersionUID
private double[]
table
private int
zeroToThirtyOne
private int
zeroToThirtyOneOccupied
-
Constructor Summary
Constructors Constructor Description DoubleHashSet()
DoubleHashSet(double... elements)
DoubleHashSet(int initialCapacity)
DoubleHashSet(DoubleIterable elements)
DoubleHashSet(DoubleHashSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(double element)
boolean
addAll(double... source)
boolean
addAll(DoubleIterable source)
protected void
allocateTable(int sizeToAllocate)
boolean
allSatisfy(DoublePredicate predicate)
Returns true if all of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(DoublePredicate predicate)
Returns true if any of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.void
appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)
Prints a string representation of this collection onto the givenAppendable
.MutableDoubleSet
asSynchronized()
MutableDoubleSet
asUnmodifiable()
RichIterable<DoubleIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableSet<V>
collect(DoubleToObjectFunction<? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source collection.<V,R extends java.util.Collection<V>>
Rcollect(DoubleToObjectFunction<? extends V> function, R target)
Same asDoubleIterable.collect(DoubleToObjectFunction)
, only the results are added to the target Collection.void
compact()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels.boolean
contains(double value)
Returns true if the value is contained in the DoubleIterable, and false if it is not.private void
copyTable()
int
count(DoublePredicate predicate)
Returns a count of the number of elements in the DoubleIterable that return true for the specified predicate.double
detectIfNone(DoublePredicate predicate, double ifNone)
MutableDoubleIterator
doubleIterator()
Returns a primitive iterator that can be used to iterate over the DoubleIterable in an imperative style.void
each(DoubleProcedure procedure)
A synonym for forEach.DoubleSet
freeze()
Returns a frozen copy of this set.int
hashCode()
Follows the same general contract asSet.hashCode()
.<T> T
injectInto(T injectedValue, ObjectDoubleToObjectFunction<? super T,? extends T> function)
private static boolean
isBetweenZeroAndThirtyOne(double value)
private static boolean
isNonSentinel(double value)
private int
mask(int spread)
double
max()
private int
maxOccupiedWithData()
double
min()
DoubleHashSet
newEmpty()
Creates a new empty DoubleHashSet.static DoubleHashSet
newSet(DoubleIterable source)
static DoubleHashSet
newSetWith(double... source)
(package private) int
probe(double element)
(package private) int
probeThree(double element, int removedIndex)
(package private) int
probeTwo(double element, int removedIndex)
void
readExternal(java.io.ObjectInput in)
private void
rehash(int newCapacity)
private void
rehashAndGrow()
DoubleHashSet
reject(DoublePredicate predicate)
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return false for the specified predicate.<R extends MutableDoubleCollection>
Rreject(DoublePredicate predicate, R target)
Same asDoubleIterable.reject(DoublePredicate)
, only the results are added to the target MutableDoubleCollection.boolean
remove(double value)
boolean
removeAll(double... source)
boolean
removeAll(DoubleIterable source)
private boolean
removeZeroToThirtyOne(double value)
boolean
retainAll(double... source)
boolean
retainAll(DoubleIterable source)
DoubleHashSet
select(DoublePredicate predicate)
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return true for the specified predicate.<R extends MutableDoubleCollection>
Rselect(DoublePredicate predicate, R target)
Same asDoubleIterable.select(DoublePredicate)
, only the results are added to the target MutableDoubleCollection.int
size()
Returns the number of items in this iterable.private int
smallestPowerOfTwoGreaterThan(int n)
(package private) int
spreadAndMask(double element)
(package private) int
spreadTwoAndMask(double element)
double
sum()
double[]
toArray()
Converts the DoubleIterable to a primitive double array.double[]
toArray(double[] array)
Converts the DoubleIterable to a primitive double array.ImmutableDoubleSet
toImmutable()
Returns an immutable copy of this set.DoubleHashSet
with(double element)
DoubleHashSet
withAll(DoubleIterable elements)
DoubleHashSet
without(double element)
DoubleHashSet
withoutAll(DoubleIterable elements)
void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class org.eclipse.collections.impl.set.primitive.AbstractDoubleSet
cartesianProduct, equals
-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractDoubleIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.DoubleIterable
asLazy, average, averageIfEmpty, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, containsAny, containsAny, containsNone, containsNone, flatCollect, forEach, injectIntoBoolean, injectIntoByte, injectIntoChar, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, injectIntoShort, maxIfEmpty, median, medianIfEmpty, minIfEmpty, noneSatisfy, reduce, reduceIfEmpty, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList, toSortedList, toSortedListBy, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.DoubleSet
cartesianProduct, equals, isProperSubsetOf, isSubsetOf, tap
-
Methods inherited from interface org.eclipse.collections.api.collection.primitive.MutableDoubleCollection
removeIf
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.MutableDoubleSet
difference, intersect, symmetricDifference, tap, union
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_CAPACITY
private static final int DEFAULT_INITIAL_CAPACITY
- See Also:
- Constant Field Values
-
EMPTY
private static final double EMPTY
- See Also:
- Constant Field Values
-
REMOVED
private static final double REMOVED
- See Also:
- Constant Field Values
-
CACHE_LINE_SIZE
private static final int CACHE_LINE_SIZE
- See Also:
- Constant Field Values
-
KEY_SIZE
private static final int KEY_SIZE
- See Also:
- Constant Field Values
-
INITIAL_LINEAR_PROBE
private static final int INITIAL_LINEAR_PROBE
- See Also:
- Constant Field Values
-
table
private double[] table
-
occupiedWithData
private int occupiedWithData
-
occupiedWithSentinels
private int occupiedWithSentinels
-
zeroToThirtyOne
private int zeroToThirtyOne
-
zeroToThirtyOneOccupied
private int zeroToThirtyOneOccupied
-
copyOnWrite
private transient boolean copyOnWrite
-
-
Constructor Detail
-
DoubleHashSet
public DoubleHashSet()
-
DoubleHashSet
public DoubleHashSet(int initialCapacity)
-
DoubleHashSet
public DoubleHashSet(double... elements)
-
DoubleHashSet
public DoubleHashSet(DoubleIterable elements)
-
DoubleHashSet
public DoubleHashSet(DoubleHashSet set)
-
-
Method Detail
-
smallestPowerOfTwoGreaterThan
private int smallestPowerOfTwoGreaterThan(int n)
-
newSet
public static DoubleHashSet newSet(DoubleIterable source)
-
newSetWith
public static DoubleHashSet newSetWith(double... source)
-
isBetweenZeroAndThirtyOne
private static boolean isBetweenZeroAndThirtyOne(double value)
-
hashCode
public int hashCode()
Description copied from interface:DoubleSet
Follows the same general contract asSet.hashCode()
.- Specified by:
hashCode
in interfaceDoubleSet
- Specified by:
hashCode
in classAbstractDoubleSet
-
size
public int size()
Description copied from interface:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)
Description copied from interface:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString(String, String, String)
.- Specified by:
appendString
in interfacePrimitiveIterable
-
add
public boolean add(double element)
- Specified by:
add
in interfaceMutableDoubleCollection
-
addAll
public boolean addAll(double... source)
- Specified by:
addAll
in interfaceMutableDoubleCollection
-
addAll
public boolean addAll(DoubleIterable source)
- Specified by:
addAll
in interfaceMutableDoubleCollection
-
remove
public boolean remove(double value)
- Specified by:
remove
in interfaceMutableDoubleCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(double value)
-
removeAll
public boolean removeAll(DoubleIterable source)
- Specified by:
removeAll
in interfaceMutableDoubleCollection
-
removeAll
public boolean removeAll(double... source)
- Specified by:
removeAll
in interfaceMutableDoubleCollection
-
retainAll
public boolean retainAll(DoubleIterable source)
- Specified by:
retainAll
in interfaceMutableDoubleCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(double... source)
- Specified by:
retainAll
in interfaceMutableDoubleCollection
- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableDoubleCollection
-
with
public DoubleHashSet with(double element)
- Specified by:
with
in interfaceMutableDoubleCollection
- Specified by:
with
in interfaceMutableDoubleSet
-
without
public DoubleHashSet without(double element)
- Specified by:
without
in interfaceMutableDoubleCollection
- Specified by:
without
in interfaceMutableDoubleSet
-
withAll
public DoubleHashSet withAll(DoubleIterable elements)
- Specified by:
withAll
in interfaceMutableDoubleCollection
- Specified by:
withAll
in interfaceMutableDoubleSet
-
withoutAll
public DoubleHashSet withoutAll(DoubleIterable elements)
- Specified by:
withoutAll
in interfaceMutableDoubleCollection
- Specified by:
withoutAll
in interfaceMutableDoubleSet
-
asUnmodifiable
public MutableDoubleSet asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableDoubleCollection
- Specified by:
asUnmodifiable
in interfaceMutableDoubleSet
-
asSynchronized
public MutableDoubleSet asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableDoubleCollection
- Specified by:
asSynchronized
in interfaceMutableDoubleSet
-
toImmutable
public ImmutableDoubleSet toImmutable()
Description copied from interface:MutableDoubleSet
Returns an immutable copy of this set.- Specified by:
toImmutable
in interfaceDoubleSet
- Specified by:
toImmutable
in interfaceMutableDoubleCollection
- Specified by:
toImmutable
in interfaceMutableDoubleSet
-
doubleIterator
public MutableDoubleIterator doubleIterator()
Description copied from interface:DoubleIterable
Returns a primitive iterator that can be used to iterate over the DoubleIterable in an imperative style.- Specified by:
doubleIterator
in interfaceDoubleIterable
- Specified by:
doubleIterator
in interfaceMutableDoubleCollection
-
toArray
public double[] toArray()
Description copied from interface:DoubleIterable
Converts the DoubleIterable to a primitive double array.- Specified by:
toArray
in interfaceDoubleIterable
-
toArray
public double[] toArray(double[] array)
Description copied from interface:DoubleIterable
Converts the DoubleIterable to a primitive double array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.- Specified by:
toArray
in interfaceDoubleIterable
-
contains
public boolean contains(double value)
Description copied from interface:DoubleIterable
Returns true if the value is contained in the DoubleIterable, and false if it is not.- Specified by:
contains
in interfaceDoubleIterable
-
each
public void each(DoubleProcedure procedure)
Description copied from interface:DoubleIterable
A synonym for forEach.- Specified by:
each
in interfaceDoubleIterable
- Since:
- 7.0.
-
select
public DoubleHashSet select(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return true for the specified predicate.- Specified by:
select
in interfaceDoubleIterable
- Specified by:
select
in interfaceDoubleSet
- Specified by:
select
in interfaceMutableDoubleCollection
- Specified by:
select
in interfaceMutableDoubleSet
-
select
public <R extends MutableDoubleCollection> R select(DoublePredicate predicate, R target)
Description copied from interface:DoubleIterable
Same asDoubleIterable.select(DoublePredicate)
, only the results are added to the target MutableDoubleCollection.- Specified by:
select
in interfaceDoubleIterable
- Since:
- 8.1.
-
reject
public DoubleHashSet reject(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return false for the specified predicate.- Specified by:
reject
in interfaceDoubleIterable
- Specified by:
reject
in interfaceDoubleSet
- Specified by:
reject
in interfaceMutableDoubleCollection
- Specified by:
reject
in interfaceMutableDoubleSet
-
reject
public <R extends MutableDoubleCollection> R reject(DoublePredicate predicate, R target)
Description copied from interface:DoubleIterable
Same asDoubleIterable.reject(DoublePredicate)
, only the results are added to the target MutableDoubleCollection.- Specified by:
reject
in interfaceDoubleIterable
- Since:
- 8.1.
-
collect
public <V> MutableSet<V> collect(DoubleToObjectFunction<? extends V> function)
Description copied from interface:DoubleIterable
Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.- Specified by:
collect
in interfaceDoubleIterable
- Specified by:
collect
in interfaceDoubleSet
- Specified by:
collect
in interfaceMutableDoubleCollection
- Specified by:
collect
in interfaceMutableDoubleSet
-
collect
public <V,R extends java.util.Collection<V>> R collect(DoubleToObjectFunction<? extends V> function, R target)
Description copied from interface:DoubleIterable
Same asDoubleIterable.collect(DoubleToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceDoubleIterable
- Since:
- 8.1.
-
detectIfNone
public double detectIfNone(DoublePredicate predicate, double ifNone)
- Specified by:
detectIfNone
in interfaceDoubleIterable
-
count
public int count(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns a count of the number of elements in the DoubleIterable that return true for the specified predicate.- Specified by:
count
in interfaceDoubleIterable
-
anySatisfy
public boolean anySatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns true if any of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceDoubleIterable
-
allSatisfy
public boolean allSatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns true if all of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceDoubleIterable
-
sum
public double sum()
- Specified by:
sum
in interfaceDoubleIterable
-
max
public double max()
- Specified by:
max
in interfaceDoubleIterable
-
min
public double min()
- Specified by:
min
in interfaceDoubleIterable
-
freeze
public DoubleSet freeze()
Description copied from interface:MutableDoubleSet
Returns a frozen copy of this set. A frozen copy is the same thing as an immutable copy without safe-publish guarantees.- Specified by:
freeze
in interfaceDoubleSet
- Specified by:
freeze
in interfaceMutableDoubleSet
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
injectInto
public <T> T injectInto(T injectedValue, ObjectDoubleToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceDoubleIterable
-
chunk
public RichIterable<DoubleIterable> chunk(int size)
Description copied from interface:DoubleIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceDoubleIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingDoubleIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
newEmpty
public DoubleHashSet newEmpty()
Creates a new empty DoubleHashSet.- Specified by:
newEmpty
in interfaceMutableDoubleCollection
- Specified by:
newEmpty
in interfaceMutableDoubleSet
- Since:
- 9.2.
-
compact
public void compact()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels.
-
rehashAndGrow
private void rehashAndGrow()
-
rehash
private void rehash(int newCapacity)
-
allocateTable
protected void allocateTable(int sizeToAllocate)
-
probe
int probe(double element)
-
probeTwo
int probeTwo(double element, int removedIndex)
-
probeThree
int probeThree(double element, int removedIndex)
-
spreadAndMask
int spreadAndMask(double element)
-
spreadTwoAndMask
int spreadTwoAndMask(double element)
-
mask
private int mask(int spread)
-
copyTable
private void copyTable()
-
maxOccupiedWithData
private int maxOccupiedWithData()
-
isNonSentinel
private static boolean isNonSentinel(double value)
-
-