Class DoubleHashBag
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractDoubleIterable
org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag
- All Implemented Interfaces:
Externalizable
,Serializable
,DoubleBag
,MutableDoubleBag
,MutableDoubleCollection
,DoubleIterable
,PrimitiveIterable
public class DoubleHashBag extends AbstractDoubleIterable implements MutableDoubleBag, Externalizable
DoubleHashBag is similar to
HashBag
, and is memory-optimized for double primitives.
This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description DoubleHashBag()
DoubleHashBag(double... elements)
DoubleHashBag(int size)
DoubleHashBag(DoubleIterable iterable)
DoubleHashBag(DoubleHashBag bag)
-
Method Summary
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(Appendable appendable, String start, String separator, 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(Object otherBag)
Follows the same general contract asBag.equals(Object)
.void
forEach(DoubleProcedure procedure)
Applies the DoubleProcedure to each element in the DoubleIterable.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.void
readExternal(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.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(ObjectOutput out)
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractDoubleIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
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, 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.MutableDoubleBag
selectDuplicates, tap
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
Constructor Details
-
DoubleHashBag
public DoubleHashBag() -
DoubleHashBag
public DoubleHashBag(int size) -
DoubleHashBag
-
DoubleHashBag
public DoubleHashBag(double... elements) -
DoubleHashBag
-
-
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: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
- Specified by:
with
in interfaceMutableDoubleBag
- Specified by:
with
in interfaceMutableDoubleCollection
-
with
-
with
-
withAll
- Specified by:
withAll
in interfaceMutableDoubleBag
- Specified by:
withAll
in interfaceMutableDoubleCollection
-
without
- Specified by:
without
in interfaceMutableDoubleBag
- Specified by:
without
in interfaceMutableDoubleCollection
-
withoutAll
- 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
Description copied from interface:DoubleBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceDoubleBag
-
selectByOccurrences
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
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
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
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
-
add
public boolean add(double item)- Specified by:
add
in interfaceMutableDoubleCollection
-
remove
public boolean remove(double item)- Specified by:
remove
in interfaceMutableDoubleCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableDoubleCollection
-
addAll
public boolean addAll(double... source)- Specified by:
addAll
in interfaceMutableDoubleCollection
-
addAll
- Specified by:
addAll
in interfaceMutableDoubleCollection
-
removeAll
public boolean removeAll(double... source)- Specified by:
removeAll
in interfaceMutableDoubleCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableDoubleCollection
-
retainAll
- 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
-
forEach
Description copied from interface:DoubleIterable
Applies the DoubleProcedure to each element in the DoubleIterable.- Specified by:
forEach
in interfaceDoubleIterable
-
each
Description copied from interface:DoubleIterable
A synonym for forEach.- Specified by:
each
in interfaceDoubleIterable
- Since:
- 7.0.
-
select
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
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
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
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
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: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
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
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
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
- Specified by:
detectIfNone
in interfaceDoubleIterable
-
collect
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
- Specified by:
asUnmodifiable
in interfaceMutableDoubleBag
- Specified by:
asUnmodifiable
in interfaceMutableDoubleCollection
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableDoubleBag
- Specified by:
asSynchronized
in interfaceMutableDoubleCollection
-
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
Creates a new empty DoubleHashBag.- Specified by:
newEmpty
in interfaceMutableDoubleBag
- Specified by:
newEmpty
in interfaceMutableDoubleCollection
- Since:
- 9.2.
-
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
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-