Class FloatHashSet
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractFloatIterable
-
- org.eclipse.collections.impl.set.primitive.AbstractFloatSet
-
- org.eclipse.collections.impl.set.mutable.primitive.FloatHashSet
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,MutableFloatCollection
,FloatIterable
,PrimitiveIterable
,FloatSet
,MutableFloatSet
public class FloatHashSet extends AbstractFloatSet implements MutableFloatSet, 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
FloatHashSet.ImmutableFloatHashSet
private class
FloatHashSet.InternalFloatIterator
-
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 float
EMPTY
private static int
INITIAL_LINEAR_PROBE
private static int
KEY_SIZE
private int
occupiedWithData
private int
occupiedWithSentinels
private static float
REMOVED
private static long
serialVersionUID
private float[]
table
private int
zeroToThirtyOne
private int
zeroToThirtyOneOccupied
-
Constructor Summary
Constructors Constructor Description FloatHashSet()
FloatHashSet(float... elements)
FloatHashSet(int initialCapacity)
FloatHashSet(FloatIterable elements)
FloatHashSet(FloatHashSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(float element)
boolean
addAll(float... source)
boolean
addAll(FloatIterable source)
protected void
allocateTable(int sizeToAllocate)
boolean
allSatisfy(FloatPredicate predicate)
Returns true if all of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(FloatPredicate predicate)
Returns true if any of the elements in the FloatIterable 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
.MutableFloatSet
asSynchronized()
MutableFloatSet
asUnmodifiable()
RichIterable<FloatIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableSet<V>
collect(FloatToObjectFunction<? 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(FloatToObjectFunction<? extends V> function, R target)
Same asFloatIterable.collect(FloatToObjectFunction)
, 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(float value)
Returns true if the value is contained in the FloatIterable, and false if it is not.private void
copyTable()
int
count(FloatPredicate predicate)
Returns a count of the number of elements in the FloatIterable that return true for the specified predicate.float
detectIfNone(FloatPredicate predicate, float ifNone)
void
each(FloatProcedure procedure)
A synonym for forEach.MutableFloatIterator
floatIterator()
Returns a primitive iterator that can be used to iterate over the FloatIterable in an imperative style.FloatSet
freeze()
Returns a frozen copy of this set.int
hashCode()
Follows the same general contract asSet.hashCode()
.<T> T
injectInto(T injectedValue, ObjectFloatToObjectFunction<? super T,? extends T> function)
private static boolean
isBetweenZeroAndThirtyOne(float value)
private static boolean
isNonSentinel(float value)
private int
mask(int spread)
float
max()
private int
maxOccupiedWithData()
float
min()
FloatHashSet
newEmpty()
Creates a new empty FloatHashSet.static FloatHashSet
newSet(FloatIterable source)
static FloatHashSet
newSetWith(float... source)
(package private) int
probe(float element)
(package private) int
probeThree(float element, int removedIndex)
(package private) int
probeTwo(float element, int removedIndex)
void
readExternal(java.io.ObjectInput in)
private void
rehash(int newCapacity)
private void
rehashAndGrow()
FloatHashSet
reject(FloatPredicate predicate)
Returns a new FloatIterable with all of the elements in the FloatIterable that return false for the specified predicate.<R extends MutableFloatCollection>
Rreject(FloatPredicate predicate, R target)
Same asFloatIterable.reject(FloatPredicate)
, only the results are added to the target MutableFloatCollection.boolean
remove(float value)
boolean
removeAll(float... source)
boolean
removeAll(FloatIterable source)
private boolean
removeZeroToThirtyOne(float value)
boolean
retainAll(float... source)
boolean
retainAll(FloatIterable source)
FloatHashSet
select(FloatPredicate predicate)
Returns a new FloatIterable with all of the elements in the FloatIterable that return true for the specified predicate.<R extends MutableFloatCollection>
Rselect(FloatPredicate predicate, R target)
Same asFloatIterable.select(FloatPredicate)
, only the results are added to the target MutableFloatCollection.int
size()
Returns the number of items in this iterable.private int
smallestPowerOfTwoGreaterThan(int n)
(package private) int
spreadAndMask(float element)
(package private) int
spreadTwoAndMask(float element)
double
sum()
float[]
toArray()
Converts the FloatIterable to a primitive float array.float[]
toArray(float[] array)
Converts the FloatIterable to a primitive float array.ImmutableFloatSet
toImmutable()
Returns an immutable copy of this set.FloatHashSet
with(float element)
FloatHashSet
withAll(FloatIterable elements)
FloatHashSet
without(float element)
FloatHashSet
withoutAll(FloatIterable elements)
void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class org.eclipse.collections.impl.set.primitive.AbstractFloatSet
cartesianProduct, equals
-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractFloatIterable
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.FloatIterable
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.FloatSet
cartesianProduct, equals, isProperSubsetOf, isSubsetOf, tap
-
Methods inherited from interface org.eclipse.collections.api.collection.primitive.MutableFloatCollection
removeIf
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.MutableFloatSet
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 float EMPTY
- See Also:
- Constant Field Values
-
REMOVED
private static final float 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 float[] table
-
occupiedWithData
private int occupiedWithData
-
occupiedWithSentinels
private int occupiedWithSentinels
-
zeroToThirtyOne
private int zeroToThirtyOne
-
zeroToThirtyOneOccupied
private int zeroToThirtyOneOccupied
-
copyOnWrite
private transient boolean copyOnWrite
-
-
Constructor Detail
-
FloatHashSet
public FloatHashSet()
-
FloatHashSet
public FloatHashSet(int initialCapacity)
-
FloatHashSet
public FloatHashSet(float... elements)
-
FloatHashSet
public FloatHashSet(FloatIterable elements)
-
FloatHashSet
public FloatHashSet(FloatHashSet set)
-
-
Method Detail
-
smallestPowerOfTwoGreaterThan
private int smallestPowerOfTwoGreaterThan(int n)
-
newSet
public static FloatHashSet newSet(FloatIterable source)
-
newSetWith
public static FloatHashSet newSetWith(float... source)
-
isBetweenZeroAndThirtyOne
private static boolean isBetweenZeroAndThirtyOne(float value)
-
hashCode
public int hashCode()
Description copied from interface:FloatSet
Follows the same general contract asSet.hashCode()
.- Specified by:
hashCode
in interfaceFloatSet
- Specified by:
hashCode
in classAbstractFloatSet
-
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(float element)
- Specified by:
add
in interfaceMutableFloatCollection
-
addAll
public boolean addAll(float... source)
- Specified by:
addAll
in interfaceMutableFloatCollection
-
addAll
public boolean addAll(FloatIterable source)
- Specified by:
addAll
in interfaceMutableFloatCollection
-
remove
public boolean remove(float value)
- Specified by:
remove
in interfaceMutableFloatCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(float value)
-
removeAll
public boolean removeAll(FloatIterable source)
- Specified by:
removeAll
in interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(float... source)
- Specified by:
removeAll
in interfaceMutableFloatCollection
-
retainAll
public boolean retainAll(FloatIterable source)
- Specified by:
retainAll
in interfaceMutableFloatCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(float... source)
- Specified by:
retainAll
in interfaceMutableFloatCollection
- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableFloatCollection
-
with
public FloatHashSet with(float element)
- Specified by:
with
in interfaceMutableFloatCollection
- Specified by:
with
in interfaceMutableFloatSet
-
without
public FloatHashSet without(float element)
- Specified by:
without
in interfaceMutableFloatCollection
- Specified by:
without
in interfaceMutableFloatSet
-
withAll
public FloatHashSet withAll(FloatIterable elements)
- Specified by:
withAll
in interfaceMutableFloatCollection
- Specified by:
withAll
in interfaceMutableFloatSet
-
withoutAll
public FloatHashSet withoutAll(FloatIterable elements)
- Specified by:
withoutAll
in interfaceMutableFloatCollection
- Specified by:
withoutAll
in interfaceMutableFloatSet
-
asUnmodifiable
public MutableFloatSet asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableFloatCollection
- Specified by:
asUnmodifiable
in interfaceMutableFloatSet
-
asSynchronized
public MutableFloatSet asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableFloatCollection
- Specified by:
asSynchronized
in interfaceMutableFloatSet
-
toImmutable
public ImmutableFloatSet toImmutable()
Description copied from interface:MutableFloatSet
Returns an immutable copy of this set.- Specified by:
toImmutable
in interfaceFloatSet
- Specified by:
toImmutable
in interfaceMutableFloatCollection
- Specified by:
toImmutable
in interfaceMutableFloatSet
-
floatIterator
public MutableFloatIterator floatIterator()
Description copied from interface:FloatIterable
Returns a primitive iterator that can be used to iterate over the FloatIterable in an imperative style.- Specified by:
floatIterator
in interfaceFloatIterable
- Specified by:
floatIterator
in interfaceMutableFloatCollection
-
toArray
public float[] toArray()
Description copied from interface:FloatIterable
Converts the FloatIterable to a primitive float array.- Specified by:
toArray
in interfaceFloatIterable
-
toArray
public float[] toArray(float[] array)
Description copied from interface:FloatIterable
Converts the FloatIterable to a primitive float 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 interfaceFloatIterable
-
contains
public boolean contains(float value)
Description copied from interface:FloatIterable
Returns true if the value is contained in the FloatIterable, and false if it is not.- Specified by:
contains
in interfaceFloatIterable
-
each
public void each(FloatProcedure procedure)
Description copied from interface:FloatIterable
A synonym for forEach.- Specified by:
each
in interfaceFloatIterable
- Since:
- 7.0.
-
select
public FloatHashSet select(FloatPredicate predicate)
Description copied from interface:FloatIterable
Returns a new FloatIterable with all of the elements in the FloatIterable that return true for the specified predicate.- Specified by:
select
in interfaceFloatIterable
- Specified by:
select
in interfaceFloatSet
- Specified by:
select
in interfaceMutableFloatCollection
- Specified by:
select
in interfaceMutableFloatSet
-
select
public <R extends MutableFloatCollection> R select(FloatPredicate predicate, R target)
Description copied from interface:FloatIterable
Same asFloatIterable.select(FloatPredicate)
, only the results are added to the target MutableFloatCollection.- Specified by:
select
in interfaceFloatIterable
- Since:
- 8.1.
-
reject
public FloatHashSet reject(FloatPredicate predicate)
Description copied from interface:FloatIterable
Returns a new FloatIterable with all of the elements in the FloatIterable that return false for the specified predicate.- Specified by:
reject
in interfaceFloatIterable
- Specified by:
reject
in interfaceFloatSet
- Specified by:
reject
in interfaceMutableFloatCollection
- Specified by:
reject
in interfaceMutableFloatSet
-
reject
public <R extends MutableFloatCollection> R reject(FloatPredicate predicate, R target)
Description copied from interface:FloatIterable
Same asFloatIterable.reject(FloatPredicate)
, only the results are added to the target MutableFloatCollection.- Specified by:
reject
in interfaceFloatIterable
- Since:
- 8.1.
-
collect
public <V> MutableSet<V> collect(FloatToObjectFunction<? extends V> function)
Description copied from interface:FloatIterable
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 interfaceFloatIterable
- Specified by:
collect
in interfaceFloatSet
- Specified by:
collect
in interfaceMutableFloatCollection
- Specified by:
collect
in interfaceMutableFloatSet
-
collect
public <V,R extends java.util.Collection<V>> R collect(FloatToObjectFunction<? extends V> function, R target)
Description copied from interface:FloatIterable
Same asFloatIterable.collect(FloatToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceFloatIterable
- Since:
- 8.1.
-
detectIfNone
public float detectIfNone(FloatPredicate predicate, float ifNone)
- Specified by:
detectIfNone
in interfaceFloatIterable
-
count
public int count(FloatPredicate predicate)
Description copied from interface:FloatIterable
Returns a count of the number of elements in the FloatIterable that return true for the specified predicate.- Specified by:
count
in interfaceFloatIterable
-
anySatisfy
public boolean anySatisfy(FloatPredicate predicate)
Description copied from interface:FloatIterable
Returns true if any of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceFloatIterable
-
allSatisfy
public boolean allSatisfy(FloatPredicate predicate)
Description copied from interface:FloatIterable
Returns true if all of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceFloatIterable
-
sum
public double sum()
- Specified by:
sum
in interfaceFloatIterable
-
max
public float max()
- Specified by:
max
in interfaceFloatIterable
-
min
public float min()
- Specified by:
min
in interfaceFloatIterable
-
freeze
public FloatSet freeze()
Description copied from interface:MutableFloatSet
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 interfaceFloatSet
- Specified by:
freeze
in interfaceMutableFloatSet
-
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, ObjectFloatToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceFloatIterable
-
chunk
public RichIterable<FloatIterable> chunk(int size)
Description copied from interface:FloatIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceFloatIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingFloatIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
newEmpty
public FloatHashSet newEmpty()
Creates a new empty FloatHashSet.- Specified by:
newEmpty
in interfaceMutableFloatCollection
- Specified by:
newEmpty
in interfaceMutableFloatSet
- 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(float element)
-
probeTwo
int probeTwo(float element, int removedIndex)
-
probeThree
int probeThree(float element, int removedIndex)
-
spreadAndMask
int spreadAndMask(float element)
-
spreadTwoAndMask
int spreadTwoAndMask(float element)
-
mask
private int mask(int spread)
-
copyTable
private void copyTable()
-
maxOccupiedWithData
private int maxOccupiedWithData()
-
isNonSentinel
private static boolean isNonSentinel(float value)
-
-