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 classFloatHashSet.ImmutableFloatHashSetprivate classFloatHashSet.InternalFloatIterator
-
Field Summary
Fields Modifier and Type Field Description private static intCACHE_LINE_SIZEprivate booleancopyOnWriteprivate static intDEFAULT_INITIAL_CAPACITYprivate static floatEMPTYprivate static intINITIAL_LINEAR_PROBEprivate static intKEY_SIZEprivate intoccupiedWithDataprivate intoccupiedWithSentinelsprivate static floatREMOVEDprivate static longserialVersionUIDprivate float[]tableprivate intzeroToThirtyOneprivate intzeroToThirtyOneOccupied
-
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 Deprecated Methods Modifier and Type Method Description booleanadd(float element)booleanaddAll(float... source)booleanaddAll(FloatIterable source)protected voidallocateTable(int sizeToAllocate)booleanallSatisfy(FloatPredicate predicate)Returns true if all of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(FloatPredicate predicate)Returns true if any of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.voidappendString(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.MutableFloatSetasSynchronized()MutableFloatSetasUnmodifiable()MutableSet<java.lang.Float>boxed()RichIterable<FloatIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<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.voidcompact()Deprecated.since 12.0 - UsetrimToSize()insteadbooleancontains(float value)Returns true if the value is contained in the FloatIterable, and false if it is not.private voidcopyTable()intcount(FloatPredicate predicate)Returns a count of the number of elements in the FloatIterable that return true for the specified predicate.floatdetectIfNone(FloatPredicate predicate, float ifNone)voideach(FloatProcedure procedure)A synonym for forEach.MutableFloatIteratorfloatIterator()Returns a primitive iterator that can be used to iterate over the FloatIterable in an imperative style.FloatSetfreeze()Returns a frozen copy of this set.inthashCode()Follows the same general contract asSet.hashCode().<T> TinjectInto(T injectedValue, ObjectFloatToObjectFunction<? super T,? extends T> function)private static booleanisBetweenZeroAndThirtyOne(float value)private static booleanisNonSentinel(float value)private intmask(int spread)floatmax()private intmaxOccupiedWithData()floatmin()FloatHashSetnewEmpty()Creates a new empty FloatHashSet.static FloatHashSetnewSet(FloatIterable source)static FloatHashSetnewSetWith(float... source)(package private) intprobe(float element)(package private) intprobeThree(float element, int removedIndex)(package private) intprobeTwo(float element, int removedIndex)voidreadExternal(java.io.ObjectInput in)private voidrehash(int newCapacity)private voidrehashAndGrow()FloatHashSetreject(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.booleanremove(float value)booleanremoveAll(float... source)booleanremoveAll(FloatIterable source)private booleanremoveZeroToThirtyOne(float value)booleanretainAll(float... source)booleanretainAll(FloatIterable source)FloatHashSetselect(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.intsize()Returns the number of items in this iterable.private intsmallestPowerOfTwoGreaterThan(int n)(package private) intspreadAndMask(float element)(package private) intspreadTwoAndMask(float element)doublesum()float[]toArray()Converts the FloatIterable to a primitive float array.float[]toArray(float[] array)Converts the FloatIterable to a primitive float array.ImmutableFloatSettoImmutable()Returns an immutable copy of this set.booleantrimToSize()FloatHashSetwith(float element)FloatHashSetwithAll(FloatIterable elements)FloatHashSetwithout(float element)FloatHashSetwithoutAll(FloatIterable elements)voidwriteExternal(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
-
boxed
public MutableSet<java.lang.Float> boxed()
- Specified by:
boxedin interfaceMutableFloatSet
-
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:FloatSetFollows the same general contract asSet.hashCode().- Specified by:
hashCodein interfaceFloatSet- Specified by:
hashCodein classAbstractFloatSet
-
size
public int size()
Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein 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:PrimitiveIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byPrimitiveIterable.makeString(String, String, String).- Specified by:
appendStringin interfacePrimitiveIterable
-
add
public boolean add(float element)
- Specified by:
addin interfaceMutableFloatCollection
-
addAll
public boolean addAll(float... source)
- Specified by:
addAllin interfaceMutableFloatCollection
-
addAll
public boolean addAll(FloatIterable source)
- Specified by:
addAllin interfaceMutableFloatCollection
-
remove
public boolean remove(float value)
- Specified by:
removein interfaceMutableFloatCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(float value)
-
removeAll
public boolean removeAll(FloatIterable source)
- Specified by:
removeAllin interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(float... source)
- Specified by:
removeAllin interfaceMutableFloatCollection
-
retainAll
public boolean retainAll(FloatIterable source)
- Specified by:
retainAllin interfaceMutableFloatCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(float... source)
- Specified by:
retainAllin interfaceMutableFloatCollection- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clearin interfaceMutableFloatCollection
-
with
public FloatHashSet with(float element)
- Specified by:
within interfaceMutableFloatCollection- Specified by:
within interfaceMutableFloatSet
-
without
public FloatHashSet without(float element)
- Specified by:
withoutin interfaceMutableFloatCollection- Specified by:
withoutin interfaceMutableFloatSet
-
withAll
public FloatHashSet withAll(FloatIterable elements)
- Specified by:
withAllin interfaceMutableFloatCollection- Specified by:
withAllin interfaceMutableFloatSet
-
withoutAll
public FloatHashSet withoutAll(FloatIterable elements)
- Specified by:
withoutAllin interfaceMutableFloatCollection- Specified by:
withoutAllin interfaceMutableFloatSet
-
asUnmodifiable
public MutableFloatSet asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableFloatCollection- Specified by:
asUnmodifiablein interfaceMutableFloatSet
-
asSynchronized
public MutableFloatSet asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableFloatCollection- Specified by:
asSynchronizedin interfaceMutableFloatSet
-
toImmutable
public ImmutableFloatSet toImmutable()
Description copied from interface:MutableFloatSetReturns an immutable copy of this set.- Specified by:
toImmutablein interfaceFloatSet- Specified by:
toImmutablein interfaceMutableFloatCollection- Specified by:
toImmutablein interfaceMutableFloatSet
-
floatIterator
public MutableFloatIterator floatIterator()
Description copied from interface:FloatIterableReturns a primitive iterator that can be used to iterate over the FloatIterable in an imperative style.- Specified by:
floatIteratorin interfaceFloatIterable- Specified by:
floatIteratorin interfaceMutableFloatCollection
-
toArray
public float[] toArray()
Description copied from interface:FloatIterableConverts the FloatIterable to a primitive float array.- Specified by:
toArrayin interfaceFloatIterable
-
toArray
public float[] toArray(float[] array)
Description copied from interface:FloatIterableConverts 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:
toArrayin interfaceFloatIterable
-
contains
public boolean contains(float value)
Description copied from interface:FloatIterableReturns true if the value is contained in the FloatIterable, and false if it is not.- Specified by:
containsin interfaceFloatIterable
-
each
public void each(FloatProcedure procedure)
Description copied from interface:FloatIterableA synonym for forEach.- Specified by:
eachin interfaceFloatIterable- Since:
- 7.0.
-
select
public FloatHashSet select(FloatPredicate predicate)
Description copied from interface:FloatIterableReturns a new FloatIterable with all of the elements in the FloatIterable that return true for the specified predicate.- Specified by:
selectin interfaceFloatIterable- Specified by:
selectin interfaceFloatSet- Specified by:
selectin interfaceMutableFloatCollection- Specified by:
selectin interfaceMutableFloatSet
-
select
public <R extends MutableFloatCollection> R select(FloatPredicate predicate, R target)
Description copied from interface:FloatIterableSame asFloatIterable.select(FloatPredicate), only the results are added to the target MutableFloatCollection.- Specified by:
selectin interfaceFloatIterable- Since:
- 8.1.
-
reject
public FloatHashSet reject(FloatPredicate predicate)
Description copied from interface:FloatIterableReturns a new FloatIterable with all of the elements in the FloatIterable that return false for the specified predicate.- Specified by:
rejectin interfaceFloatIterable- Specified by:
rejectin interfaceFloatSet- Specified by:
rejectin interfaceMutableFloatCollection- Specified by:
rejectin interfaceMutableFloatSet
-
reject
public <R extends MutableFloatCollection> R reject(FloatPredicate predicate, R target)
Description copied from interface:FloatIterableSame asFloatIterable.reject(FloatPredicate), only the results are added to the target MutableFloatCollection.- Specified by:
rejectin interfaceFloatIterable- Since:
- 8.1.
-
collect
public <V> MutableSet<V> collect(FloatToObjectFunction<? extends V> function)
Description copied from interface:FloatIterableReturns 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:
collectin interfaceFloatIterable- Specified by:
collectin interfaceFloatSet- Specified by:
collectin interfaceMutableFloatCollection- Specified by:
collectin interfaceMutableFloatSet
-
collect
public <V,R extends java.util.Collection<V>> R collect(FloatToObjectFunction<? extends V> function, R target)
Description copied from interface:FloatIterableSame asFloatIterable.collect(FloatToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceFloatIterable- Since:
- 8.1.
-
detectIfNone
public float detectIfNone(FloatPredicate predicate, float ifNone)
- Specified by:
detectIfNonein interfaceFloatIterable
-
count
public int count(FloatPredicate predicate)
Description copied from interface:FloatIterableReturns a count of the number of elements in the FloatIterable that return true for the specified predicate.- Specified by:
countin interfaceFloatIterable
-
anySatisfy
public boolean anySatisfy(FloatPredicate predicate)
Description copied from interface:FloatIterableReturns true if any of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceFloatIterable
-
allSatisfy
public boolean allSatisfy(FloatPredicate predicate)
Description copied from interface:FloatIterableReturns true if all of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceFloatIterable
-
sum
public double sum()
- Specified by:
sumin interfaceFloatIterable
-
max
public float max()
- Specified by:
maxin interfaceFloatIterable
-
min
public float min()
- Specified by:
minin interfaceFloatIterable
-
freeze
public FloatSet freeze()
Description copied from interface:MutableFloatSetReturns a frozen copy of this set. A frozen copy is the same thing as an immutable copy without safe-publish guarantees.- Specified by:
freezein interfaceFloatSet- Specified by:
freezein interfaceMutableFloatSet
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
injectInto
public <T> T injectInto(T injectedValue, ObjectFloatToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceFloatIterable
-
chunk
public RichIterable<FloatIterable> chunk(int size)
Description copied from interface:FloatIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceFloatIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingFloatIterables 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:
newEmptyin interfaceMutableFloatCollection- Specified by:
newEmptyin interfaceMutableFloatSet- Since:
- 9.2.
-
trimToSize
public boolean trimToSize()
- Since:
- 12.0
-
compact
@Deprecated public void compact()
Deprecated.since 12.0 - UsetrimToSize()insteadRehashes 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)
-
-