Class LongHashBag
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractLongIterable
org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag
- All Implemented Interfaces:
Externalizable
,Serializable
,LongBag
,MutableLongBag
,MutableLongCollection
,LongIterable
,PrimitiveIterable
public class LongHashBag extends AbstractLongIterable implements MutableLongBag, Externalizable
LongHashBag is similar to
HashBag
, and is memory-optimized for long primitives.
This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description LongHashBag()
LongHashBag(int size)
LongHashBag(long... elements)
LongHashBag(LongIterable iterable)
LongHashBag(LongHashBag bag)
-
Method Summary
Modifier and Type Method Description boolean
add(long item)
boolean
addAll(long... source)
boolean
addAll(LongIterable source)
void
addOccurrences(long item, int occurrences)
boolean
allSatisfy(LongPredicate predicate)
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(LongPredicate predicate)
Returns true if any of the elements in the LongIterable 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
.MutableLongBag
asSynchronized()
MutableLongBag
asUnmodifiable()
MutableList<LongIntPair>
bottomOccurrences(int count)
Returns thecount
least frequently occurring items.RichIterable<LongIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableBag<V>
collect(LongToObjectFunction<? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source collection.boolean
contains(long value)
Returns true if the value is contained in the LongIterable, and false if it is not.int
count(LongPredicate predicate)
Returns a count of the number of elements in the LongIterable that return true for the specified predicate.long
detectIfNone(LongPredicate predicate, long ifNone)
void
each(LongProcedure procedure)
A synonym for forEach.boolean
equals(Object otherBag)
Follows the same general contract asBag.equals(Object)
.void
forEach(LongProcedure procedure)
Applies the LongProcedure to each element in the LongIterable.void
forEachWithOccurrences(LongIntProcedure 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, ObjectLongToObjectFunction<? super T,? extends T> function)
boolean
isEmpty()
Returns true if this iterable has zero items.MutableLongIterator
longIterator()
Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.long
max()
long
min()
static LongHashBag
newBag(int size)
static LongHashBag
newBag(LongBag source)
static LongHashBag
newBag(LongIterable source)
static LongHashBag
newBagWith(long... source)
LongHashBag
newEmpty()
Creates a new empty LongHashBag.boolean
noneSatisfy(LongPredicate predicate)
Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.boolean
notEmpty()
The English equivalent of !this.isEmpty()int
occurrencesOf(long item)
The occurrences of a distinct item in the bag.void
readExternal(ObjectInput in)
LongHashBag
reject(LongPredicate predicate)
Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.boolean
remove(long item)
boolean
removeAll(long... source)
boolean
removeAll(LongIterable source)
boolean
removeIf(LongPredicate predicate)
boolean
removeOccurrences(long item, int occurrences)
boolean
retainAll(long... source)
boolean
retainAll(LongIterable source)
LongHashBag
select(LongPredicate predicate)
Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.LongHashBag
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableLongSet
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.long
sum()
long[]
toArray()
Converts the LongIterable to a primitive long array.long[]
toArray(long[] array)
Converts the LongIterable to a primitive long array.ImmutableLongBag
toImmutable()
Returns an immutable copy of this bag.MutableList<LongIntPair>
topOccurrences(int count)
Returns thecount
most frequently occurring items.LongHashBag
with(long element)
LongHashBag
with(long element1, long element2)
LongHashBag
with(long element1, long element2, long element3)
LongHashBag
withAll(LongIterable iterable)
LongHashBag
without(long element)
LongHashBag
withoutAll(LongIterable iterable)
void
writeExternal(ObjectOutput out)
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractLongIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.bag.primitive.LongBag
toStringOfItemToCount
Methods inherited from interface org.eclipse.collections.api.LongIterable
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.MutableLongBag
selectDuplicates, tap
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
Constructor Details
-
LongHashBag
public LongHashBag() -
LongHashBag
public LongHashBag(int size) -
LongHashBag
-
LongHashBag
public LongHashBag(long... elements) -
LongHashBag
-
-
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:LongBag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceLongBag
-
clear
public void clear()- Specified by:
clear
in interfaceMutableLongCollection
-
with
- Specified by:
with
in interfaceMutableLongBag
- Specified by:
with
in interfaceMutableLongCollection
-
with
-
with
-
withAll
- Specified by:
withAll
in interfaceMutableLongBag
- Specified by:
withAll
in interfaceMutableLongCollection
-
without
- Specified by:
without
in interfaceMutableLongBag
- Specified by:
without
in interfaceMutableLongCollection
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableLongBag
- Specified by:
withoutAll
in interfaceMutableLongCollection
-
contains
public boolean contains(long value)Description copied from interface:LongIterable
Returns true if the value is contained in the LongIterable, and false if it is not.- Specified by:
contains
in interfaceLongIterable
-
occurrencesOf
public int occurrencesOf(long item)Description copied from interface:LongBag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceLongBag
-
forEachWithOccurrences
Description copied from interface:LongBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceLongBag
-
selectByOccurrences
Description copied from interface:MutableLongBag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceLongBag
- Specified by:
selectByOccurrences
in interfaceMutableLongBag
-
selectUnique
Description copied from interface:MutableLongBag
Returns all elements of the bag that have exactly one occurrence.- Specified by:
selectUnique
in interfaceLongBag
- Specified by:
selectUnique
in interfaceMutableLongBag
-
topOccurrences
Description copied from interface:MutableLongBag
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 interfaceLongBag
- Specified by:
topOccurrences
in interfaceMutableLongBag
-
bottomOccurrences
Description copied from interface:MutableLongBag
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 interfaceLongBag
- Specified by:
bottomOccurrences
in interfaceMutableLongBag
-
add
public boolean add(long item)- Specified by:
add
in interfaceMutableLongCollection
-
remove
public boolean remove(long item)- Specified by:
remove
in interfaceMutableLongCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableLongCollection
-
addAll
public boolean addAll(long... source)- Specified by:
addAll
in interfaceMutableLongCollection
-
addAll
- Specified by:
addAll
in interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source)- Specified by:
removeAll
in interfaceMutableLongCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableLongCollection
-
retainAll
- Specified by:
retainAll
in interfaceMutableLongCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(long... source)- Specified by:
retainAll
in interfaceMutableLongCollection
- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(long item, int occurrences)- Specified by:
addOccurrences
in interfaceMutableLongBag
-
removeOccurrences
public boolean removeOccurrences(long item, int occurrences)- Specified by:
removeOccurrences
in interfaceMutableLongBag
-
forEach
Description copied from interface:LongIterable
Applies the LongProcedure to each element in the LongIterable.- Specified by:
forEach
in interfaceLongIterable
-
each
Description copied from interface:LongIterable
A synonym for forEach.- Specified by:
each
in interfaceLongIterable
- Since:
- 7.0.
-
select
Description copied from interface:LongIterable
Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.- Specified by:
select
in interfaceLongBag
- Specified by:
select
in interfaceLongIterable
- Specified by:
select
in interfaceMutableLongBag
- Specified by:
select
in interfaceMutableLongCollection
-
reject
Description copied from interface:LongIterable
Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.- Specified by:
reject
in interfaceLongBag
- Specified by:
reject
in interfaceLongIterable
- Specified by:
reject
in interfaceMutableLongBag
- Specified by:
reject
in interfaceMutableLongCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)- Specified by:
injectInto
in interfaceLongIterable
-
chunk
Description copied from interface:LongIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceLongIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingLongIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
equals
Description copied from interface:LongBag
Follows the same general contract asBag.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:LongBag
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:LongIterable
Returns a count of the number of elements in the LongIterable that return true for the specified predicate.- Specified by:
count
in interfaceLongIterable
-
anySatisfy
Description copied from interface:LongIterable
Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceLongIterable
-
allSatisfy
Description copied from interface:LongIterable
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceLongIterable
-
noneSatisfy
Description copied from interface:LongIterable
Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceLongIterable
-
detectIfNone
- Specified by:
detectIfNone
in interfaceLongIterable
-
collect
Description copied from interface:LongIterable
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 interfaceLongBag
- Specified by:
collect
in interfaceLongIterable
- Specified by:
collect
in interfaceMutableLongBag
- Specified by:
collect
in interfaceMutableLongCollection
-
max
public long max()- Specified by:
max
in interfaceLongIterable
-
min
public long min()- Specified by:
min
in interfaceLongIterable
-
sum
public long sum()- Specified by:
sum
in interfaceLongIterable
-
toArray
public long[] toArray()Description copied from interface:LongIterable
Converts the LongIterable to a primitive long array.- Specified by:
toArray
in interfaceLongIterable
-
toArray
public long[] toArray(long[] array)Description copied from interface:LongIterable
Converts the LongIterable to a primitive long 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 interfaceLongIterable
-
asUnmodifiable
- Specified by:
asUnmodifiable
in interfaceMutableLongBag
- Specified by:
asUnmodifiable
in interfaceMutableLongCollection
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableLongBag
- Specified by:
asSynchronized
in interfaceMutableLongCollection
-
toImmutable
Description copied from interface:MutableLongBag
Returns an immutable copy of this bag.- Specified by:
toImmutable
in interfaceLongBag
- Specified by:
toImmutable
in interfaceMutableLongBag
- Specified by:
toImmutable
in interfaceMutableLongCollection
-
newEmpty
Creates a new empty LongHashBag.- Specified by:
newEmpty
in interfaceMutableLongBag
- Specified by:
newEmpty
in interfaceMutableLongCollection
- Since:
- 9.2.
-
longIterator
Description copied from interface:LongIterable
Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.- Specified by:
longIterator
in interfaceLongIterable
- Specified by:
longIterator
in interfaceMutableLongCollection
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-