Class DoubleHashBag
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractDoubleIterable
-
- org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,DoubleBag,MutableDoubleBag,MutableDoubleCollection,DoubleIterable,PrimitiveIterable
public class DoubleHashBag extends AbstractDoubleIterable implements MutableDoubleBag, java.io.Externalizable
DoubleHashBag is similar toHashBag, and is memory-optimized for double 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 classDoubleHashBag.InternalIterator
-
Field Summary
Fields Modifier and Type Field Description private DoubleIntHashMapitemsprivate static longserialVersionUIDprivate intsize
-
Constructor Summary
Constructors Constructor Description DoubleHashBag()DoubleHashBag(double... elements)DoubleHashBag(int size)DoubleHashBag(DoubleIterable iterable)DoubleHashBag(DoubleHashBag bag)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(double item)booleanaddAll(double... source)booleanaddAll(DoubleIterable source)voidaddOccurrences(double item, int occurrences)booleanallSatisfy(DoublePredicate predicate)Returns true if all of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(DoublePredicate predicate)Returns true if any of the elements in the DoubleIterable 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.MutableDoubleBagasSynchronized()MutableDoubleBagasUnmodifiable()MutableList<DoubleIntPair>bottomOccurrences(int count)Returns thecountleast frequently occurring items.RichIterable<DoubleIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<V> MutableBag<V>collect(DoubleToObjectFunction<? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.booleancontains(double value)Returns true if the value is contained in the DoubleIterable, and false if it is not.intcount(DoublePredicate predicate)Returns a count of the number of elements in the DoubleIterable that return true for the specified predicate.doubledetectIfNone(DoublePredicate predicate, double ifNone)MutableDoubleIteratordoubleIterator()Returns a primitive iterator that can be used to iterate over the DoubleIterable in an imperative style.voideach(DoubleProcedure procedure)A synonym for forEach.booleanequals(java.lang.Object otherBag)Follows the same general contract asBag.equals(Object).voidforEachWithOccurrences(DoubleIntProcedure 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, ObjectDoubleToObjectFunction<? super T,? extends T> function)booleanisEmpty()Returns true if this iterable has zero items.doublemax()doublemin()static DoubleHashBagnewBag(int size)static DoubleHashBagnewBag(DoubleBag source)static DoubleHashBagnewBag(DoubleIterable source)static DoubleHashBagnewBagWith(double... source)DoubleHashBagnewEmpty()Creates a new empty DoubleHashBag.booleannoneSatisfy(DoublePredicate predicate)Returns true if none of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.booleannotEmpty()The English equivalent of !this.isEmpty()intoccurrencesOf(double item)The occurrences of a distinct item in the bag.protected MutableList<DoubleIntPair>occurrencesSortingBy(int n, IntFunction<DoubleIntPair> function, MutableList<DoubleIntPair> returnWhenEmpty)voidreadExternal(java.io.ObjectInput in)DoubleHashBagreject(DoublePredicate predicate)Returns a new DoubleIterable with all of the elements in the DoubleIterable that return false for the specified predicate.booleanremove(double item)booleanremoveAll(double... source)booleanremoveAll(DoubleIterable source)booleanremoveIf(DoublePredicate predicate)booleanremoveOccurrences(double item, int occurrences)booleanretainAll(double... source)booleanretainAll(DoubleIterable source)DoubleHashBagselect(DoublePredicate predicate)Returns a new DoubleIterable with all of the elements in the DoubleIterable that return true for the specified predicate.DoubleHashBagselectByOccurrences(IntPredicate predicate)Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableDoubleSetselectUnique()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()double[]toArray()Converts the DoubleIterable to a primitive double array.double[]toArray(double[] array)Converts the DoubleIterable to a primitive double array.ImmutableDoubleBagtoImmutable()Returns an immutable copy of this bag.protected MutableList<DoubleIntPair>toListWithOccurrences()MutableList<DoubleIntPair>topOccurrences(int count)Returns thecountmost frequently occurring items.DoubleHashBagwith(double element)DoubleHashBagwith(double element1, double element2)DoubleHashBagwith(double element1, double element2, double element3)DoubleHashBagwithAll(DoubleIterable iterable)DoubleHashBagwithout(double element)DoubleHashBagwithoutAll(DoubleIterable iterable)voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractDoubleIterable
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.DoubleBag
toStringOfItemToCount
-
Methods inherited from interface org.eclipse.collections.api.DoubleIterable
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.MutableDoubleBag
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 DoubleIntHashMap items
-
size
private int size
-
-
Constructor Detail
-
DoubleHashBag
public DoubleHashBag()
-
DoubleHashBag
public DoubleHashBag(int size)
-
DoubleHashBag
public DoubleHashBag(DoubleIterable iterable)
-
DoubleHashBag
public DoubleHashBag(double... elements)
-
DoubleHashBag
public DoubleHashBag(DoubleHashBag bag)
-
-
Method Detail
-
newBag
public static DoubleHashBag newBag(int size)
-
newBagWith
public static DoubleHashBag newBagWith(double... source)
-
newBag
public static DoubleHashBag newBag(DoubleIterable source)
-
newBag
public static DoubleHashBag newBag(DoubleBag 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:DoubleBagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceDoubleBag
-
clear
public void clear()
- Specified by:
clearin interfaceMutableDoubleCollection
-
with
public DoubleHashBag with(double element)
- Specified by:
within interfaceMutableDoubleBag- Specified by:
within interfaceMutableDoubleCollection
-
with
public DoubleHashBag with(double element1, double element2)
-
with
public DoubleHashBag with(double element1, double element2, double element3)
-
withAll
public DoubleHashBag withAll(DoubleIterable iterable)
- Specified by:
withAllin interfaceMutableDoubleBag- Specified by:
withAllin interfaceMutableDoubleCollection
-
without
public DoubleHashBag without(double element)
- Specified by:
withoutin interfaceMutableDoubleBag- Specified by:
withoutin interfaceMutableDoubleCollection
-
withoutAll
public DoubleHashBag withoutAll(DoubleIterable iterable)
- Specified by:
withoutAllin interfaceMutableDoubleBag- Specified by:
withoutAllin interfaceMutableDoubleCollection
-
contains
public boolean contains(double value)
Description copied from interface:DoubleIterableReturns true if the value is contained in the DoubleIterable, and false if it is not.- Specified by:
containsin interfaceDoubleIterable
-
occurrencesOf
public int occurrencesOf(double item)
Description copied from interface:DoubleBagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceDoubleBag
-
forEachWithOccurrences
public void forEachWithOccurrences(DoubleIntProcedure procedure)
Description copied from interface:DoubleBagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceDoubleBag
-
selectByOccurrences
public DoubleHashBag selectByOccurrences(IntPredicate predicate)
Description copied from interface:MutableDoubleBagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceDoubleBag- Specified by:
selectByOccurrencesin interfaceMutableDoubleBag
-
selectUnique
public MutableDoubleSet selectUnique()
Description copied from interface:MutableDoubleBagReturns all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceDoubleBag- Specified by:
selectUniquein interfaceMutableDoubleBag
-
topOccurrences
public MutableList<DoubleIntPair> topOccurrences(int count)
Description copied from interface:MutableDoubleBagReturns 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 interfaceDoubleBag- Specified by:
topOccurrencesin interfaceMutableDoubleBag
-
bottomOccurrences
public MutableList<DoubleIntPair> bottomOccurrences(int count)
Description copied from interface:MutableDoubleBagReturns 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 interfaceDoubleBag- Specified by:
bottomOccurrencesin interfaceMutableDoubleBag
-
occurrencesSortingBy
protected MutableList<DoubleIntPair> occurrencesSortingBy(int n, IntFunction<DoubleIntPair> function, MutableList<DoubleIntPair> returnWhenEmpty)
-
toListWithOccurrences
protected MutableList<DoubleIntPair> toListWithOccurrences()
-
add
public boolean add(double item)
- Specified by:
addin interfaceMutableDoubleCollection
-
remove
public boolean remove(double item)
- Specified by:
removein interfaceMutableDoubleCollection
-
removeIf
public boolean removeIf(DoublePredicate predicate)
- Specified by:
removeIfin interfaceMutableDoubleCollection
-
addAll
public boolean addAll(double... source)
- Specified by:
addAllin interfaceMutableDoubleCollection
-
addAll
public boolean addAll(DoubleIterable source)
- Specified by:
addAllin interfaceMutableDoubleCollection
-
removeAll
public boolean removeAll(double... source)
- Specified by:
removeAllin interfaceMutableDoubleCollection
-
removeAll
public boolean removeAll(DoubleIterable source)
- Specified by:
removeAllin interfaceMutableDoubleCollection
-
retainAll
public boolean retainAll(DoubleIterable source)
- Specified by:
retainAllin interfaceMutableDoubleCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(double... source)
- Specified by:
retainAllin interfaceMutableDoubleCollection- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(double item, int occurrences)- Specified by:
addOccurrencesin interfaceMutableDoubleBag
-
removeOccurrences
public boolean removeOccurrences(double item, int occurrences)- Specified by:
removeOccurrencesin interfaceMutableDoubleBag
-
each
public void each(DoubleProcedure procedure)
Description copied from interface:DoubleIterableA synonym for forEach.- Specified by:
eachin interfaceDoubleIterable- Since:
- 7.0.
-
select
public DoubleHashBag select(DoublePredicate predicate)
Description copied from interface:DoubleIterableReturns a new DoubleIterable with all of the elements in the DoubleIterable that return true for the specified predicate.- Specified by:
selectin interfaceDoubleBag- Specified by:
selectin interfaceDoubleIterable- Specified by:
selectin interfaceMutableDoubleBag- Specified by:
selectin interfaceMutableDoubleCollection
-
reject
public DoubleHashBag reject(DoublePredicate predicate)
Description copied from interface:DoubleIterableReturns a new DoubleIterable with all of the elements in the DoubleIterable that return false for the specified predicate.- Specified by:
rejectin interfaceDoubleBag- Specified by:
rejectin interfaceDoubleIterable- Specified by:
rejectin interfaceMutableDoubleBag- Specified by:
rejectin interfaceMutableDoubleCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectDoubleToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceDoubleIterable
-
chunk
public RichIterable<DoubleIterable> chunk(int size)
Description copied from interface:DoubleIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceDoubleIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingDoubleIterables 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:DoubleBagFollows the same general contract asBag.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:DoubleBagFollows 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(DoublePredicate predicate)
Description copied from interface:DoubleIterableReturns a count of the number of elements in the DoubleIterable that return true for the specified predicate.- Specified by:
countin interfaceDoubleIterable
-
anySatisfy
public boolean anySatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterableReturns true if any of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceDoubleIterable
-
allSatisfy
public boolean allSatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterableReturns true if all of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceDoubleIterable
-
noneSatisfy
public boolean noneSatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterableReturns true if none of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceDoubleIterable
-
detectIfNone
public double detectIfNone(DoublePredicate predicate, double ifNone)
- Specified by:
detectIfNonein interfaceDoubleIterable
-
collect
public <V> MutableBag<V> collect(DoubleToObjectFunction<? extends V> function)
Description copied from interface:DoubleIterableReturns 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 interfaceDoubleBag- Specified by:
collectin interfaceDoubleIterable- Specified by:
collectin interfaceMutableDoubleBag- Specified by:
collectin interfaceMutableDoubleCollection
-
max
public double max()
- Specified by:
maxin interfaceDoubleIterable
-
min
public double min()
- Specified by:
minin interfaceDoubleIterable
-
sum
public double sum()
- Specified by:
sumin interfaceDoubleIterable
-
toArray
public double[] toArray()
Description copied from interface:DoubleIterableConverts the DoubleIterable to a primitive double array.- Specified by:
toArrayin interfaceDoubleIterable
-
toArray
public double[] toArray(double[] array)
Description copied from interface:DoubleIterableConverts the DoubleIterable to a primitive double 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 interfaceDoubleIterable
-
asUnmodifiable
public MutableDoubleBag asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableDoubleBag- Specified by:
asUnmodifiablein interfaceMutableDoubleCollection
-
asSynchronized
public MutableDoubleBag asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableDoubleBag- Specified by:
asSynchronizedin interfaceMutableDoubleCollection
-
toImmutable
public ImmutableDoubleBag toImmutable()
Description copied from interface:MutableDoubleBagReturns an immutable copy of this bag.- Specified by:
toImmutablein interfaceDoubleBag- Specified by:
toImmutablein interfaceMutableDoubleBag- Specified by:
toImmutablein interfaceMutableDoubleCollection
-
newEmpty
public DoubleHashBag newEmpty()
Creates a new empty DoubleHashBag.- Specified by:
newEmptyin interfaceMutableDoubleBag- Specified by:
newEmptyin interfaceMutableDoubleCollection- Since:
- 9.2.
-
doubleIterator
public MutableDoubleIterator doubleIterator()
Description copied from interface:DoubleIterableReturns a primitive iterator that can be used to iterate over the DoubleIterable in an imperative style.- Specified by:
doubleIteratorin interfaceDoubleIterable- Specified by:
doubleIteratorin interfaceMutableDoubleCollection
-
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
-
-