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 classFloatHashBag.InternalIterator
-
Field Summary
Fields Modifier and Type Field Description private FloatIntHashMapitemsprivate static longserialVersionUIDprivate intsize
-
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 booleanadd(float item)booleanaddAll(float... source)booleanaddAll(FloatIterable source)voidaddOccurrences(float item, int occurrences)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.MutableFloatBagasSynchronized()MutableFloatBagasUnmodifiable()MutableList<FloatIntPair>bottomOccurrences(int count)Returns thecountleast frequently occurring items.RichIterable<FloatIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<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.booleancontains(float value)Returns true if the value is contained in the FloatIterable, and false if it is not.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.booleanequals(java.lang.Object otherBag)Follows the same general contract asBag.equals(Object).MutableFloatIteratorfloatIterator()Returns a primitive iterator that can be used to iterate over the FloatIterable in an imperative style.voidforEachWithOccurrences(FloatIntProcedure procedure)For each distinct item, with the number of occurrences, execute the specified procedure.inthashCode()Follows the same general contract asBag.hashCode().<T> TinjectInto(T injectedValue, ObjectFloatToObjectFunction<? super T,? extends T> function)booleanisEmpty()Returns true if this iterable has zero items.floatmax()floatmin()static FloatHashBagnewBag(int size)static FloatHashBagnewBag(FloatBag source)static FloatHashBagnewBag(FloatIterable source)static FloatHashBagnewBagWith(float... source)FloatHashBagnewEmpty()Creates a new empty FloatHashBag.booleannoneSatisfy(FloatPredicate predicate)Returns true if none of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.booleannotEmpty()The English equivalent of !this.isEmpty()intoccurrencesOf(float item)The occurrences of a distinct item in the bag.protected MutableList<FloatIntPair>occurrencesSortingBy(int n, IntFunction<FloatIntPair> function, MutableList<FloatIntPair> returnWhenEmpty)voidreadExternal(java.io.ObjectInput in)FloatHashBagreject(FloatPredicate predicate)Returns a new FloatIterable with all of the elements in the FloatIterable that return false for the specified predicate.booleanremove(float item)booleanremoveAll(float... source)booleanremoveAll(FloatIterable source)booleanremoveIf(FloatPredicate predicate)booleanremoveOccurrences(float item, int occurrences)booleanretainAll(float... source)booleanretainAll(FloatIterable source)FloatHashBagselect(FloatPredicate predicate)Returns a new FloatIterable with all of the elements in the FloatIterable that return true for the specified predicate.FloatHashBagselectByOccurrences(IntPredicate predicate)Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableFloatSetselectUnique()Returns all elements of the bag that have exactly one occurrence.intsize()Returns the number of items in this iterable.intsizeDistinct()The size of the Bag when counting only distinct elements.doublesum()float[]toArray()Converts the FloatIterable to a primitive float array.float[]toArray(float[] array)Converts the FloatIterable to a primitive float array.ImmutableFloatBagtoImmutable()Returns an immutable copy of this bag.protected MutableList<FloatIntPair>toListWithOccurrences()MutableList<FloatIntPair>topOccurrences(int count)Returns thecountmost frequently occurring items.FloatHashBagwith(float element)FloatHashBagwith(float element1, float element2)FloatHashBagwith(float element1, float element2, float element3)FloatHashBagwithAll(FloatIterable iterable)FloatHashBagwithout(float element)FloatHashBagwithoutAll(FloatIterable iterable)voidwriteExternal(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:PrimitiveIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfacePrimitiveIterable
-
notEmpty
public boolean notEmpty()
Description copied from interface:PrimitiveIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfacePrimitiveIterable
-
size
public int size()
Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein interfacePrimitiveIterable
-
sizeDistinct
public int sizeDistinct()
Description copied from interface:FloatBagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceFloatBag
-
clear
public void clear()
- Specified by:
clearin interfaceMutableFloatCollection
-
with
public FloatHashBag with(float element)
- Specified by:
within interfaceMutableFloatBag- Specified by:
within 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:
withAllin interfaceMutableFloatBag- Specified by:
withAllin interfaceMutableFloatCollection
-
without
public FloatHashBag without(float element)
- Specified by:
withoutin interfaceMutableFloatBag- Specified by:
withoutin interfaceMutableFloatCollection
-
withoutAll
public FloatHashBag withoutAll(FloatIterable iterable)
- Specified by:
withoutAllin interfaceMutableFloatBag- Specified by:
withoutAllin interfaceMutableFloatCollection
-
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
-
occurrencesOf
public int occurrencesOf(float item)
Description copied from interface:FloatBagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceFloatBag
-
forEachWithOccurrences
public void forEachWithOccurrences(FloatIntProcedure procedure)
Description copied from interface:FloatBagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceFloatBag
-
selectByOccurrences
public FloatHashBag selectByOccurrences(IntPredicate predicate)
Description copied from interface:MutableFloatBagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceFloatBag- Specified by:
selectByOccurrencesin interfaceMutableFloatBag
-
selectUnique
public MutableFloatSet selectUnique()
Description copied from interface:MutableFloatBagReturns all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceFloatBag- Specified by:
selectUniquein interfaceMutableFloatBag
-
topOccurrences
public MutableList<FloatIntPair> topOccurrences(int count)
Description copied from interface:MutableFloatBagReturns thecountmost 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:
topOccurrencesin interfaceFloatBag- Specified by:
topOccurrencesin interfaceMutableFloatBag
-
bottomOccurrences
public MutableList<FloatIntPair> bottomOccurrences(int count)
Description copied from interface:MutableFloatBagReturns thecountleast 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:
bottomOccurrencesin interfaceFloatBag- Specified by:
bottomOccurrencesin 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:
addin interfaceMutableFloatCollection
-
remove
public boolean remove(float item)
- Specified by:
removein interfaceMutableFloatCollection
-
removeIf
public boolean removeIf(FloatPredicate predicate)
- Specified by:
removeIfin interfaceMutableFloatCollection
-
addAll
public boolean addAll(float... source)
- Specified by:
addAllin interfaceMutableFloatCollection
-
addAll
public boolean addAll(FloatIterable source)
- Specified by:
addAllin interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(float... source)
- Specified by:
removeAllin interfaceMutableFloatCollection
-
removeAll
public boolean removeAll(FloatIterable 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)
-
addOccurrences
public void addOccurrences(float item, int occurrences)- Specified by:
addOccurrencesin interfaceMutableFloatBag
-
removeOccurrences
public boolean removeOccurrences(float item, int occurrences)- Specified by:
removeOccurrencesin interfaceMutableFloatBag
-
each
public void each(FloatProcedure procedure)
Description copied from interface:FloatIterableA synonym for forEach.- Specified by:
eachin interfaceFloatIterable- Since:
- 7.0.
-
select
public FloatHashBag 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 interfaceFloatBag- Specified by:
selectin interfaceFloatIterable- Specified by:
selectin interfaceMutableFloatBag- Specified by:
selectin interfaceMutableFloatCollection
-
reject
public FloatHashBag 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 interfaceFloatBag- Specified by:
rejectin interfaceFloatIterable- Specified by:
rejectin interfaceMutableFloatBag- Specified by:
rejectin interfaceMutableFloatCollection
-
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.
-
equals
public boolean equals(java.lang.Object otherBag)
Description copied from interface:FloatBagFollows the same general contract asBag.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:FloatBagFollows 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:PrimitiveIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byPrimitiveIterable.makeString(String, String, String).- Specified by:
appendStringin interfacePrimitiveIterable
-
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
-
noneSatisfy
public boolean noneSatisfy(FloatPredicate predicate)
Description copied from interface:FloatIterableReturns true if none of the elements in the FloatIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceFloatIterable
-
detectIfNone
public float detectIfNone(FloatPredicate predicate, float ifNone)
- Specified by:
detectIfNonein interfaceFloatIterable
-
collect
public <V> MutableBag<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 interfaceFloatBag- Specified by:
collectin interfaceFloatIterable- Specified by:
collectin interfaceMutableFloatBag- Specified by:
collectin interfaceMutableFloatCollection
-
max
public float max()
- Specified by:
maxin interfaceFloatIterable
-
min
public float min()
- Specified by:
minin interfaceFloatIterable
-
sum
public double sum()
- Specified by:
sumin interfaceFloatIterable
-
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
-
asUnmodifiable
public MutableFloatBag asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableFloatBag- Specified by:
asUnmodifiablein interfaceMutableFloatCollection
-
asSynchronized
public MutableFloatBag asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableFloatBag- Specified by:
asSynchronizedin interfaceMutableFloatCollection
-
toImmutable
public ImmutableFloatBag toImmutable()
Description copied from interface:MutableFloatBagReturns an immutable copy of this bag.- Specified by:
toImmutablein interfaceFloatBag- Specified by:
toImmutablein interfaceMutableFloatBag- Specified by:
toImmutablein interfaceMutableFloatCollection
-
newEmpty
public FloatHashBag newEmpty()
Creates a new empty FloatHashBag.- Specified by:
newEmptyin interfaceMutableFloatBag- Specified by:
newEmptyin interfaceMutableFloatCollection- Since:
- 9.2.
-
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
-
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
-
-