Class FloatHashBag
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractFloatIterable
-
- org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,FloatBag
,MutableFloatBag
,MutableFloatCollection
,FloatIterable
,PrimitiveIterable
public class FloatHashBag extends AbstractFloatIterable implements MutableFloatBag, java.io.Externalizable
FloatHashBag is similar toHashBag
, and is memory-optimized for float primitives. This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
FloatHashBag.InternalIterator
-
Field Summary
Fields Modifier and Type Field Description private FloatIntHashMap
items
private static long
serialVersionUID
private int
size
-
Constructor Summary
Constructors Constructor Description FloatHashBag()
FloatHashBag(float... elements)
FloatHashBag(int size)
FloatHashBag(FloatIterable iterable)
FloatHashBag(FloatHashBag bag)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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(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
.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(java.lang.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
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.protected MutableList<FloatIntPair>
occurrencesSortingBy(int n, IntFunction<FloatIntPair> function, MutableList<FloatIntPair> returnWhenEmpty)
void
readExternal(java.io.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.protected MutableList<FloatIntPair>
toListWithOccurrences()
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(java.io.ObjectOutput out)
-
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.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, containsAny, containsAny, containsNone, containsNone, flatCollect, forEach, injectIntoBoolean, injectIntoByte, injectIntoChar, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, injectIntoShort, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList, toSortedList, toSortedListBy, toSortedListBy
-
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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
items
private FloatIntHashMap items
-
size
private int size
-
-
Constructor Detail
-
FloatHashBag
public FloatHashBag()
-
FloatHashBag
public FloatHashBag(int size)
-
FloatHashBag
public FloatHashBag(FloatIterable iterable)
-
FloatHashBag
public FloatHashBag(float... elements)
-
FloatHashBag
public FloatHashBag(FloatHashBag bag)
-
-
Method Detail
-
newBag
public static FloatHashBag newBag(int size)
-
newBagWith
public static FloatHashBag newBagWith(float... source)
-
newBag
public static FloatHashBag newBag(FloatIterable source)
-
newBag
public static FloatHashBag newBag(FloatBag source)
-
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
public FloatHashBag with(float element)
- Specified by:
with
in interfaceMutableFloatBag
- Specified by:
with
in interfaceMutableFloatCollection
-
with
public FloatHashBag with(float element1, float element2)
-
with
public FloatHashBag with(float element1, float element2, float element3)
-
withAll
public FloatHashBag withAll(FloatIterable iterable)
- Specified by:
withAll
in interfaceMutableFloatBag
- Specified by:
withAll
in interfaceMutableFloatCollection
-
without
public FloatHashBag without(float element)
- Specified by:
without
in interfaceMutableFloatBag
- Specified by:
without
in interfaceMutableFloatCollection
-
withoutAll
public FloatHashBag withoutAll(FloatIterable iterable)
- 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
public void forEachWithOccurrences(FloatIntProcedure procedure)
Description copied from interface:FloatBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceFloatBag
-
selectByOccurrences
public FloatHashBag selectByOccurrences(IntPredicate predicate)
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
public MutableFloatSet 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
public MutableList<FloatIntPair> topOccurrences(int count)
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
public MutableList<FloatIntPair> bottomOccurrences(int count)
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
-
occurrencesSortingBy
protected MutableList<FloatIntPair> occurrencesSortingBy(int n, IntFunction<FloatIntPair> function, MutableList<FloatIntPair> returnWhenEmpty)
-
toListWithOccurrences
protected MutableList<FloatIntPair> toListWithOccurrences()
-
add
public boolean add(float item)
- Specified by:
add
in interfaceMutableFloatCollection
-
remove
public boolean remove(float item)
- Specified by:
remove
in interfaceMutableFloatCollection
-
removeIf
public boolean removeIf(FloatPredicate predicate)
- Specified by:
removeIf
in interfaceMutableFloatCollection
-
addAll
public boolean addAll(float... source)
- Specified by:
addAll
in interfaceMutableFloatCollection
-
addAll
public boolean addAll(FloatIterable source)
- Specified by:
addAll
in interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(float... source)
- Specified by:
removeAll
in interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(FloatIterable 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)
-
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
-
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 FloatHashBag 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 interfaceFloatBag
- Specified by:
select
in interfaceFloatIterable
- Specified by:
select
in interfaceMutableFloatBag
- Specified by:
select
in interfaceMutableFloatCollection
-
reject
public FloatHashBag 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 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
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.
-
equals
public boolean equals(java.lang.Object otherBag)
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
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
-
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
-
noneSatisfy
public boolean noneSatisfy(FloatPredicate predicate)
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
public float detectIfNone(FloatPredicate predicate, float ifNone)
- Specified by:
detectIfNone
in interfaceFloatIterable
-
collect
public <V> MutableBag<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 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
public MutableFloatBag asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableFloatBag
- Specified by:
asUnmodifiable
in interfaceMutableFloatCollection
-
asSynchronized
public MutableFloatBag asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableFloatBag
- Specified by:
asSynchronized
in interfaceMutableFloatCollection
-
toImmutable
public ImmutableFloatBag 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
public FloatHashBag newEmpty()
Creates a new empty FloatHashBag.- Specified by:
newEmpty
in interfaceMutableFloatBag
- Specified by:
newEmpty
in interfaceMutableFloatCollection
- Since:
- 9.2.
-
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
-
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
-
-