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 class
DoubleHashBag.InternalIterator
-
Field Summary
Fields Modifier and Type Field Description private DoubleIntHashMap
items
private static long
serialVersionUID
private int
size
-
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 boolean
add(double item)
boolean
addAll(double... source)
boolean
addAll(DoubleIterable source)
void
addOccurrences(double item, int occurrences)
boolean
allSatisfy(DoublePredicate predicate)
Returns true if all of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(DoublePredicate predicate)
Returns true if any of the elements in the DoubleIterable 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
.MutableDoubleBag
asSynchronized()
MutableDoubleBag
asUnmodifiable()
MutableList<DoubleIntPair>
bottomOccurrences(int count)
Returns thecount
least frequently occurring items.RichIterable<DoubleIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<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.boolean
contains(double value)
Returns true if the value is contained in the DoubleIterable, and false if it is not.int
count(DoublePredicate predicate)
Returns a count of the number of elements in the DoubleIterable that return true for the specified predicate.double
detectIfNone(DoublePredicate predicate, double ifNone)
MutableDoubleIterator
doubleIterator()
Returns a primitive iterator that can be used to iterate over the DoubleIterable in an imperative style.void
each(DoubleProcedure procedure)
A synonym for forEach.boolean
equals(java.lang.Object otherBag)
Follows the same general contract asBag.equals(Object)
.void
forEachWithOccurrences(DoubleIntProcedure 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, ObjectDoubleToObjectFunction<? super T,? extends T> function)
boolean
isEmpty()
Returns true if this iterable has zero items.double
max()
double
min()
static DoubleHashBag
newBag(int size)
static DoubleHashBag
newBag(DoubleBag source)
static DoubleHashBag
newBag(DoubleIterable source)
static DoubleHashBag
newBagWith(double... source)
DoubleHashBag
newEmpty()
Creates a new empty DoubleHashBag.boolean
noneSatisfy(DoublePredicate predicate)
Returns true if none of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.boolean
notEmpty()
The English equivalent of !this.isEmpty()int
occurrencesOf(double item)
The occurrences of a distinct item in the bag.protected MutableList<DoubleIntPair>
occurrencesSortingBy(int n, IntFunction<DoubleIntPair> function, MutableList<DoubleIntPair> returnWhenEmpty)
void
readExternal(java.io.ObjectInput in)
DoubleHashBag
reject(DoublePredicate predicate)
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return false for the specified predicate.boolean
remove(double item)
boolean
removeAll(double... source)
boolean
removeAll(DoubleIterable source)
boolean
removeIf(DoublePredicate predicate)
boolean
removeOccurrences(double item, int occurrences)
boolean
retainAll(double... source)
boolean
retainAll(DoubleIterable source)
DoubleHashBag
select(DoublePredicate predicate)
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return true for the specified predicate.DoubleHashBag
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableDoubleSet
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()
double[]
toArray()
Converts the DoubleIterable to a primitive double array.double[]
toArray(double[] array)
Converts the DoubleIterable to a primitive double array.ImmutableDoubleBag
toImmutable()
Returns an immutable copy of this bag.protected MutableList<DoubleIntPair>
toListWithOccurrences()
MutableList<DoubleIntPair>
topOccurrences(int count)
Returns thecount
most frequently occurring items.DoubleHashBag
with(double element)
DoubleHashBag
with(double element1, double element2)
DoubleHashBag
with(double element1, double element2, double element3)
DoubleHashBag
withAll(DoubleIterable iterable)
DoubleHashBag
without(double element)
DoubleHashBag
withoutAll(DoubleIterable iterable)
void
writeExternal(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: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:DoubleBag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceDoubleBag
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableDoubleCollection
-
with
public DoubleHashBag with(double element)
- Specified by:
with
in interfaceMutableDoubleBag
- Specified by:
with
in 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:
withAll
in interfaceMutableDoubleBag
- Specified by:
withAll
in interfaceMutableDoubleCollection
-
without
public DoubleHashBag without(double element)
- Specified by:
without
in interfaceMutableDoubleBag
- Specified by:
without
in interfaceMutableDoubleCollection
-
withoutAll
public DoubleHashBag withoutAll(DoubleIterable iterable)
- Specified by:
withoutAll
in interfaceMutableDoubleBag
- Specified by:
withoutAll
in interfaceMutableDoubleCollection
-
contains
public boolean contains(double value)
Description copied from interface:DoubleIterable
Returns true if the value is contained in the DoubleIterable, and false if it is not.- Specified by:
contains
in interfaceDoubleIterable
-
occurrencesOf
public int occurrencesOf(double item)
Description copied from interface:DoubleBag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceDoubleBag
-
forEachWithOccurrences
public void forEachWithOccurrences(DoubleIntProcedure procedure)
Description copied from interface:DoubleBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceDoubleBag
-
selectByOccurrences
public DoubleHashBag selectByOccurrences(IntPredicate predicate)
Description copied from interface:MutableDoubleBag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceDoubleBag
- Specified by:
selectByOccurrences
in interfaceMutableDoubleBag
-
selectUnique
public MutableDoubleSet selectUnique()
Description copied from interface:MutableDoubleBag
Returns all elements of the bag that have exactly one occurrence.- Specified by:
selectUnique
in interfaceDoubleBag
- Specified by:
selectUnique
in interfaceMutableDoubleBag
-
topOccurrences
public MutableList<DoubleIntPair> topOccurrences(int count)
Description copied from interface:MutableDoubleBag
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 interfaceDoubleBag
- Specified by:
topOccurrences
in interfaceMutableDoubleBag
-
bottomOccurrences
public MutableList<DoubleIntPair> bottomOccurrences(int count)
Description copied from interface:MutableDoubleBag
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 interfaceDoubleBag
- Specified by:
bottomOccurrences
in 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:
add
in interfaceMutableDoubleCollection
-
remove
public boolean remove(double item)
- Specified by:
remove
in interfaceMutableDoubleCollection
-
removeIf
public boolean removeIf(DoublePredicate predicate)
- Specified by:
removeIf
in interfaceMutableDoubleCollection
-
addAll
public boolean addAll(double... source)
- Specified by:
addAll
in interfaceMutableDoubleCollection
-
addAll
public boolean addAll(DoubleIterable source)
- Specified by:
addAll
in interfaceMutableDoubleCollection
-
removeAll
public boolean removeAll(double... source)
- Specified by:
removeAll
in interfaceMutableDoubleCollection
-
removeAll
public boolean removeAll(DoubleIterable source)
- Specified by:
removeAll
in interfaceMutableDoubleCollection
-
retainAll
public boolean retainAll(DoubleIterable source)
- Specified by:
retainAll
in interfaceMutableDoubleCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(double... source)
- Specified by:
retainAll
in interfaceMutableDoubleCollection
- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(double item, int occurrences)
- Specified by:
addOccurrences
in interfaceMutableDoubleBag
-
removeOccurrences
public boolean removeOccurrences(double item, int occurrences)
- Specified by:
removeOccurrences
in interfaceMutableDoubleBag
-
each
public void each(DoubleProcedure procedure)
Description copied from interface:DoubleIterable
A synonym for forEach.- Specified by:
each
in interfaceDoubleIterable
- Since:
- 7.0.
-
select
public DoubleHashBag select(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return true for the specified predicate.- Specified by:
select
in interfaceDoubleBag
- Specified by:
select
in interfaceDoubleIterable
- Specified by:
select
in interfaceMutableDoubleBag
- Specified by:
select
in interfaceMutableDoubleCollection
-
reject
public DoubleHashBag reject(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns a new DoubleIterable with all of the elements in the DoubleIterable that return false for the specified predicate.- Specified by:
reject
in interfaceDoubleBag
- Specified by:
reject
in interfaceDoubleIterable
- Specified by:
reject
in interfaceMutableDoubleBag
- Specified by:
reject
in interfaceMutableDoubleCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectDoubleToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceDoubleIterable
-
chunk
public RichIterable<DoubleIterable> chunk(int size)
Description copied from interface:DoubleIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceDoubleIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingDoubleIterable
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:DoubleBag
Follows the same general contract asBag.equals(Object)
.
-
hashCode
public int hashCode()
Description copied from interface:DoubleBag
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(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns a count of the number of elements in the DoubleIterable that return true for the specified predicate.- Specified by:
count
in interfaceDoubleIterable
-
anySatisfy
public boolean anySatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns true if any of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceDoubleIterable
-
allSatisfy
public boolean allSatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns true if all of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceDoubleIterable
-
noneSatisfy
public boolean noneSatisfy(DoublePredicate predicate)
Description copied from interface:DoubleIterable
Returns true if none of the elements in the DoubleIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceDoubleIterable
-
detectIfNone
public double detectIfNone(DoublePredicate predicate, double ifNone)
- Specified by:
detectIfNone
in interfaceDoubleIterable
-
collect
public <V> MutableBag<V> collect(DoubleToObjectFunction<? extends V> function)
Description copied from interface:DoubleIterable
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 interfaceDoubleBag
- Specified by:
collect
in interfaceDoubleIterable
- Specified by:
collect
in interfaceMutableDoubleBag
- Specified by:
collect
in interfaceMutableDoubleCollection
-
max
public double max()
- Specified by:
max
in interfaceDoubleIterable
-
min
public double min()
- Specified by:
min
in interfaceDoubleIterable
-
sum
public double sum()
- Specified by:
sum
in interfaceDoubleIterable
-
toArray
public double[] toArray()
Description copied from interface:DoubleIterable
Converts the DoubleIterable to a primitive double array.- Specified by:
toArray
in interfaceDoubleIterable
-
toArray
public double[] toArray(double[] array)
Description copied from interface:DoubleIterable
Converts 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:
toArray
in interfaceDoubleIterable
-
asUnmodifiable
public MutableDoubleBag asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableDoubleBag
- Specified by:
asUnmodifiable
in interfaceMutableDoubleCollection
-
asSynchronized
public MutableDoubleBag asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableDoubleBag
- Specified by:
asSynchronized
in interfaceMutableDoubleCollection
-
toImmutable
public ImmutableDoubleBag toImmutable()
Description copied from interface:MutableDoubleBag
Returns an immutable copy of this bag.- Specified by:
toImmutable
in interfaceDoubleBag
- Specified by:
toImmutable
in interfaceMutableDoubleBag
- Specified by:
toImmutable
in interfaceMutableDoubleCollection
-
newEmpty
public DoubleHashBag newEmpty()
Creates a new empty DoubleHashBag.- Specified by:
newEmpty
in interfaceMutableDoubleBag
- Specified by:
newEmpty
in interfaceMutableDoubleCollection
- Since:
- 9.2.
-
doubleIterator
public MutableDoubleIterator doubleIterator()
Description copied from interface:DoubleIterable
Returns a primitive iterator that can be used to iterate over the DoubleIterable in an imperative style.- Specified by:
doubleIterator
in interfaceDoubleIterable
- Specified by:
doubleIterator
in interfaceMutableDoubleCollection
-
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
-
-