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 booleanadd(long item)booleanaddAll(long... source)booleanaddAll(LongIterable source)voidaddOccurrences(long item, int occurrences)booleanallSatisfy(LongPredicate predicate)Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(LongPredicate predicate)Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.voidappendString(Appendable appendable, String start, String separator, String end)Prints a string representation of this collection onto the givenAppendable.MutableLongBagasSynchronized()MutableLongBagasUnmodifiable()MutableList<LongIntPair>bottomOccurrences(int count)Returns thecountleast frequently occurring items.RichIterable<LongIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<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.booleancontains(long value)Returns true if the value is contained in the LongIterable, and false if it is not.intcount(LongPredicate predicate)Returns a count of the number of elements in the LongIterable that return true for the specified predicate.longdetectIfNone(LongPredicate predicate, long ifNone)voideach(LongProcedure procedure)A synonym for forEach.booleanequals(Object otherBag)Follows the same general contract asBag.equals(Object).voidforEach(LongProcedure procedure)Applies the LongProcedure to each element in the LongIterable.voidforEachWithOccurrences(LongIntProcedure 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, ObjectLongToObjectFunction<? super T,? extends T> function)booleanisEmpty()Returns true if this iterable has zero items.MutableLongIteratorlongIterator()Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.longmax()longmin()static LongHashBagnewBag(int size)static LongHashBagnewBag(LongBag source)static LongHashBagnewBag(LongIterable source)static LongHashBagnewBagWith(long... source)LongHashBagnewEmpty()Creates a new empty LongHashBag.booleannoneSatisfy(LongPredicate predicate)Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.booleannotEmpty()The English equivalent of !this.isEmpty()intoccurrencesOf(long item)The occurrences of a distinct item in the bag.voidreadExternal(ObjectInput in)LongHashBagreject(LongPredicate predicate)Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.booleanremove(long item)booleanremoveAll(long... source)booleanremoveAll(LongIterable source)booleanremoveIf(LongPredicate predicate)booleanremoveOccurrences(long item, int occurrences)booleanretainAll(long... source)booleanretainAll(LongIterable source)LongHashBagselect(LongPredicate predicate)Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.LongHashBagselectByOccurrences(IntPredicate predicate)Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableLongSetselectUnique()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.longsum()long[]toArray()Converts the LongIterable to a primitive long array.long[]toArray(long[] array)Converts the LongIterable to a primitive long array.ImmutableLongBagtoImmutable()Returns an immutable copy of this bag.MutableList<LongIntPair>topOccurrences(int count)Returns thecountmost frequently occurring items.LongHashBagwith(long element)LongHashBagwith(long element1, long element2)LongHashBagwith(long element1, long element2, long element3)LongHashBagwithAll(LongIterable iterable)LongHashBagwithout(long element)LongHashBagwithoutAll(LongIterable iterable)voidwriteExternal(ObjectOutput out)Methods inherited from class org.eclipse.collections.impl.primitive.AbstractLongIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface org.eclipse.collections.api.bag.primitive.LongBag
toStringOfItemToCountMethods 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, toSortedListMethods inherited from interface org.eclipse.collections.api.bag.primitive.MutableLongBag
selectDuplicates, tapMethods 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: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:LongBagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceLongBag
-
clear
public void clear()- Specified by:
clearin interfaceMutableLongCollection
-
with
- Specified by:
within interfaceMutableLongBag- Specified by:
within interfaceMutableLongCollection
-
with
-
with
-
withAll
- Specified by:
withAllin interfaceMutableLongBag- Specified by:
withAllin interfaceMutableLongCollection
-
without
- Specified by:
withoutin interfaceMutableLongBag- Specified by:
withoutin interfaceMutableLongCollection
-
withoutAll
- Specified by:
withoutAllin interfaceMutableLongBag- Specified by:
withoutAllin interfaceMutableLongCollection
-
contains
public boolean contains(long value)Description copied from interface:LongIterableReturns true if the value is contained in the LongIterable, and false if it is not.- Specified by:
containsin interfaceLongIterable
-
occurrencesOf
public int occurrencesOf(long item)Description copied from interface:LongBagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceLongBag
-
forEachWithOccurrences
Description copied from interface:LongBagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceLongBag
-
selectByOccurrences
Description copied from interface:MutableLongBagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceLongBag- Specified by:
selectByOccurrencesin interfaceMutableLongBag
-
selectUnique
Description copied from interface:MutableLongBagReturns all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceLongBag- Specified by:
selectUniquein interfaceMutableLongBag
-
topOccurrences
Description copied from interface:MutableLongBagReturns 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 interfaceLongBag- Specified by:
topOccurrencesin interfaceMutableLongBag
-
bottomOccurrences
Description copied from interface:MutableLongBagReturns 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 interfaceLongBag- Specified by:
bottomOccurrencesin interfaceMutableLongBag
-
add
public boolean add(long item)- Specified by:
addin interfaceMutableLongCollection
-
remove
public boolean remove(long item)- Specified by:
removein interfaceMutableLongCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableLongCollection
-
addAll
public boolean addAll(long... source)- Specified by:
addAllin interfaceMutableLongCollection
-
addAll
- Specified by:
addAllin interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source)- Specified by:
removeAllin interfaceMutableLongCollection
-
removeAll
- Specified by:
removeAllin interfaceMutableLongCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableLongCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(long... source)- Specified by:
retainAllin interfaceMutableLongCollection- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(long item, int occurrences)- Specified by:
addOccurrencesin interfaceMutableLongBag
-
removeOccurrences
public boolean removeOccurrences(long item, int occurrences)- Specified by:
removeOccurrencesin interfaceMutableLongBag
-
forEach
Description copied from interface:LongIterableApplies the LongProcedure to each element in the LongIterable.- Specified by:
forEachin interfaceLongIterable
-
each
Description copied from interface:LongIterableA synonym for forEach.- Specified by:
eachin interfaceLongIterable- Since:
- 7.0.
-
select
Description copied from interface:LongIterableReturns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.- Specified by:
selectin interfaceLongBag- Specified by:
selectin interfaceLongIterable- Specified by:
selectin interfaceMutableLongBag- Specified by:
selectin interfaceMutableLongCollection
-
reject
Description copied from interface:LongIterableReturns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.- Specified by:
rejectin interfaceLongBag- Specified by:
rejectin interfaceLongIterable- Specified by:
rejectin interfaceMutableLongBag- Specified by:
rejectin interfaceMutableLongCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceLongIterable
-
chunk
Description copied from interface:LongIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceLongIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingLongIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
equals
Description copied from interface:LongBagFollows the same general contract asBag.equals(Object). -
hashCode
public int hashCode()Description copied from interface:LongBagFollows the same general contract asBag.hashCode(). -
appendString
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
Description copied from interface:LongIterableReturns a count of the number of elements in the LongIterable that return true for the specified predicate.- Specified by:
countin interfaceLongIterable
-
anySatisfy
Description copied from interface:LongIterableReturns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceLongIterable
-
allSatisfy
Description copied from interface:LongIterableReturns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceLongIterable
-
noneSatisfy
Description copied from interface:LongIterableReturns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceLongIterable
-
detectIfNone
- Specified by:
detectIfNonein interfaceLongIterable
-
collect
Description copied from interface:LongIterableReturns 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 interfaceLongBag- Specified by:
collectin interfaceLongIterable- Specified by:
collectin interfaceMutableLongBag- Specified by:
collectin interfaceMutableLongCollection
-
max
public long max()- Specified by:
maxin interfaceLongIterable
-
min
public long min()- Specified by:
minin interfaceLongIterable
-
sum
public long sum()- Specified by:
sumin interfaceLongIterable
-
toArray
public long[] toArray()Description copied from interface:LongIterableConverts the LongIterable to a primitive long array.- Specified by:
toArrayin interfaceLongIterable
-
toArray
public long[] toArray(long[] array)Description copied from interface:LongIterableConverts 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:
toArrayin interfaceLongIterable
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableLongBag- Specified by:
asUnmodifiablein interfaceMutableLongCollection
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableLongBag- Specified by:
asSynchronizedin interfaceMutableLongCollection
-
toImmutable
Description copied from interface:MutableLongBagReturns an immutable copy of this bag.- Specified by:
toImmutablein interfaceLongBag- Specified by:
toImmutablein interfaceMutableLongBag- Specified by:
toImmutablein interfaceMutableLongCollection
-
newEmpty
Creates a new empty LongHashBag.- Specified by:
newEmptyin interfaceMutableLongBag- Specified by:
newEmptyin interfaceMutableLongCollection- Since:
- 9.2.
-
longIterator
Description copied from interface:LongIterableReturns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.- Specified by:
longIteratorin interfaceLongIterable- Specified by:
longIteratorin interfaceMutableLongCollection
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-