Class FloatHashBag
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractFloatIterable
org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag
- All Implemented Interfaces:
Externalizable
,Serializable
,FloatBag
,MutableFloatBag
,MutableFloatCollection
,FloatIterable
,PrimitiveIterable
public class FloatHashBag extends AbstractFloatIterable implements MutableFloatBag, Externalizable
FloatHashBag is similar to
HashBag
, and is memory-optimized for float primitives.
This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description FloatHashBag()
FloatHashBag(float... elements)
FloatHashBag(int size)
FloatHashBag(FloatIterable iterable)
FloatHashBag(FloatHashBag bag)
-
Method Summary
Modifier and Type Method Description boolean
add(float item)
boolean
addAll(float... source)
boolean
addAll(FloatIterable source)
void
addOccurrences(float item, int occurrences)
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(Appendable appendable, String start, String separator, String end)
Prints a string representation of this collection onto the givenAppendable
.MutableFloatBag
asSynchronized()
MutableFloatBag
asUnmodifiable()
MutableList<FloatIntPair>
bottomOccurrences(int count)
Returns thecount
least frequently occurring items.RichIterable<FloatIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableBag<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.boolean
contains(float value)
Returns true if the value is contained in the FloatIterable, and false if it is not.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.boolean
equals(Object otherBag)
Follows the same general contract asBag.equals(Object)
.MutableFloatIterator
floatIterator()
Returns a primitive iterator that can be used to iterate over the FloatIterable in an imperative style.void
forEach(FloatProcedure procedure)
Applies the FloatProcedure to each element in the FloatIterable.void
forEachWithOccurrences(FloatIntProcedure procedure)
For each distinct item, with the number of occurrences, execute the specified procedure.int
hashCode()
Follows the same general contract asBag.hashCode()
.<T> T
injectInto(T injectedValue, ObjectFloatToObjectFunction<? super T,? extends T> function)
boolean
isEmpty()
Returns true if this iterable has zero items.float
max()
float
min()
static FloatHashBag
newBag(int size)
static FloatHashBag
newBag(FloatBag source)
static FloatHashBag
newBag(FloatIterable source)
static FloatHashBag
newBagWith(float... source)
FloatHashBag
newEmpty()
Creates a new empty FloatHashBag.boolean
noneSatisfy(FloatPredicate predicate)
Returns true if none of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.boolean
notEmpty()
The English equivalent of !this.isEmpty()int
occurrencesOf(float item)
The occurrences of a distinct item in the bag.void
readExternal(ObjectInput in)
FloatHashBag
reject(FloatPredicate predicate)
Returns a new FloatIterable with all of the elements in the FloatIterable that return false for the specified predicate.boolean
remove(float item)
boolean
removeAll(float... source)
boolean
removeAll(FloatIterable source)
boolean
removeIf(FloatPredicate predicate)
boolean
removeOccurrences(float item, int occurrences)
boolean
retainAll(float... source)
boolean
retainAll(FloatIterable source)
FloatHashBag
select(FloatPredicate predicate)
Returns a new FloatIterable with all of the elements in the FloatIterable that return true for the specified predicate.FloatHashBag
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableFloatSet
selectUnique()
Returns all elements of the bag that have exactly one occurrence.int
size()
Returns the number of items in this iterable.int
sizeDistinct()
The size of the Bag when counting only distinct elements.double
sum()
float[]
toArray()
Converts the FloatIterable to a primitive float array.float[]
toArray(float[] array)
Converts the FloatIterable to a primitive float array.ImmutableFloatBag
toImmutable()
Returns an immutable copy of this bag.MutableList<FloatIntPair>
topOccurrences(int count)
Returns thecount
most frequently occurring items.FloatHashBag
with(float element)
FloatHashBag
with(float element1, float element2)
FloatHashBag
with(float element1, float element2, float element3)
FloatHashBag
withAll(FloatIterable iterable)
FloatHashBag
without(float element)
FloatHashBag
withoutAll(FloatIterable iterable)
void
writeExternal(ObjectOutput out)
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractFloatIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.bag.primitive.FloatBag
toStringOfItemToCount
Methods inherited from interface org.eclipse.collections.api.FloatIterable
asLazy, average, averageIfEmpty, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, flatCollect, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList
Methods inherited from interface org.eclipse.collections.api.bag.primitive.MutableFloatBag
selectDuplicates, tap
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
Constructor Details
-
FloatHashBag
public FloatHashBag() -
FloatHashBag
public FloatHashBag(int size) -
FloatHashBag
-
FloatHashBag
public FloatHashBag(float... elements) -
FloatHashBag
-
-
Method Details
-
newBag
-
newBagWith
-
newBag
-
newBag
-
isEmpty
public boolean isEmpty()Description copied from interface:PrimitiveIterable
Returns true if this iterable has zero items.- Specified by:
isEmpty
in interfacePrimitiveIterable
-
notEmpty
public boolean notEmpty()Description copied from interface:PrimitiveIterable
The English equivalent of !this.isEmpty()- Specified by:
notEmpty
in interfacePrimitiveIterable
-
size
public int size()Description copied from interface:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
sizeDistinct
public int sizeDistinct()Description copied from interface:FloatBag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceFloatBag
-
clear
public void clear()- Specified by:
clear
in interfaceMutableFloatCollection
-
with
- Specified by:
with
in interfaceMutableFloatBag
- Specified by:
with
in interfaceMutableFloatCollection
-
with
-
with
-
withAll
- Specified by:
withAll
in interfaceMutableFloatBag
- Specified by:
withAll
in interfaceMutableFloatCollection
-
without
- Specified by:
without
in interfaceMutableFloatBag
- Specified by:
without
in interfaceMutableFloatCollection
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableFloatBag
- Specified by:
withoutAll
in interfaceMutableFloatCollection
-
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
-
occurrencesOf
public int occurrencesOf(float item)Description copied from interface:FloatBag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceFloatBag
-
forEachWithOccurrences
Description copied from interface:FloatBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceFloatBag
-
selectByOccurrences
Description copied from interface:MutableFloatBag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceFloatBag
- Specified by:
selectByOccurrences
in interfaceMutableFloatBag
-
selectUnique
Description copied from interface:MutableFloatBag
Returns all elements of the bag that have exactly one occurrence.- Specified by:
selectUnique
in interfaceFloatBag
- Specified by:
selectUnique
in interfaceMutableFloatBag
-
topOccurrences
Description copied from interface:MutableFloatBag
Returns thecount
most frequently occurring items. In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last item will be returned.- Specified by:
topOccurrences
in interfaceFloatBag
- Specified by:
topOccurrences
in interfaceMutableFloatBag
-
bottomOccurrences
Description copied from interface:MutableFloatBag
Returns thecount
least frequently occurring items. In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last item will be returned.- Specified by:
bottomOccurrences
in interfaceFloatBag
- Specified by:
bottomOccurrences
in interfaceMutableFloatBag
-
add
public boolean add(float item)- Specified by:
add
in interfaceMutableFloatCollection
-
remove
public boolean remove(float item)- Specified by:
remove
in interfaceMutableFloatCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableFloatCollection
-
addAll
public boolean addAll(float... source)- Specified by:
addAll
in interfaceMutableFloatCollection
-
addAll
- Specified by:
addAll
in interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(float... source)- Specified by:
removeAll
in interfaceMutableFloatCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableFloatCollection
-
retainAll
- 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)
-
addOccurrences
public void addOccurrences(float item, int occurrences)- Specified by:
addOccurrences
in interfaceMutableFloatBag
-
removeOccurrences
public boolean removeOccurrences(float item, int occurrences)- Specified by:
removeOccurrences
in interfaceMutableFloatBag
-
forEach
Description copied from interface:FloatIterable
Applies the FloatProcedure to each element in the FloatIterable.- Specified by:
forEach
in interfaceFloatIterable
-
each
Description copied from interface:FloatIterable
A synonym for forEach.- Specified by:
each
in interfaceFloatIterable
- Since:
- 7.0.
-
select
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 interfaceFloatBag
- Specified by:
select
in interfaceFloatIterable
- Specified by:
select
in interfaceMutableFloatBag
- Specified by:
select
in interfaceMutableFloatCollection
-
reject
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 interfaceFloatBag
- Specified by:
reject
in interfaceFloatIterable
- Specified by:
reject
in interfaceMutableFloatBag
- Specified by:
reject
in interfaceMutableFloatCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectFloatToObjectFunction<? super T,? extends T> function)- Specified by:
injectInto
in interfaceFloatIterable
-
chunk
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.
-
equals
Description copied from interface:FloatBag
Follows the same general contract asBag.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:FloatBag
Follows the same general contract asBag.hashCode()
. -
appendString
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
-
count
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
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
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
-
noneSatisfy
Description copied from interface:FloatIterable
Returns true if none of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceFloatIterable
-
detectIfNone
- Specified by:
detectIfNone
in interfaceFloatIterable
-
collect
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 interfaceFloatBag
- Specified by:
collect
in interfaceFloatIterable
- Specified by:
collect
in interfaceMutableFloatBag
- Specified by:
collect
in interfaceMutableFloatCollection
-
max
public float max()- Specified by:
max
in interfaceFloatIterable
-
min
public float min()- Specified by:
min
in interfaceFloatIterable
-
sum
public double sum()- Specified by:
sum
in interfaceFloatIterable
-
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
-
asUnmodifiable
- Specified by:
asUnmodifiable
in interfaceMutableFloatBag
- Specified by:
asUnmodifiable
in interfaceMutableFloatCollection
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableFloatBag
- Specified by:
asSynchronized
in interfaceMutableFloatCollection
-
toImmutable
Description copied from interface:MutableFloatBag
Returns an immutable copy of this bag.- Specified by:
toImmutable
in interfaceFloatBag
- Specified by:
toImmutable
in interfaceMutableFloatBag
- Specified by:
toImmutable
in interfaceMutableFloatCollection
-
newEmpty
Creates a new empty FloatHashBag.- Specified by:
newEmpty
in interfaceMutableFloatBag
- Specified by:
newEmpty
in interfaceMutableFloatCollection
- Since:
- 9.2.
-
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
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-