Class IntHashBag
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractIntIterable
org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag
- All Implemented Interfaces:
Externalizable, Serializable, IntBag, MutableIntBag, MutableIntCollection, IntIterable, PrimitiveIterable
IntHashBag is similar to
HashBag, and is memory-optimized for int primitives.
This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIntHashBag(int size) IntHashBag(int... elements) IntHashBag(IntIterable iterable) IntHashBag(IntHashBag bag) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int item) booleanaddAll(int... source) booleanaddAll(IntIterable source) voidaddOccurrences(int item, int occurrences) booleanallSatisfy(IntPredicate predicate) Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(IntPredicate predicate) Returns true if any of the elements in the IntIterable 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.bottomOccurrences(int count) Returns thecountleast frequently occurring items.chunk(int size) Partitions elements in fixed size chunks.voidclear()<V> MutableBag<V> collect(IntToObjectFunction<? extends V> function) Returns a new collection with the results of applying the specified function on each element of the source collection.booleancontains(int value) Returns true if the value is contained in the IntIterable, and false if it is not.intcount(IntPredicate predicate) Returns a count of the number of elements in the IntIterable that return true for the specified predicate.intdetectIfNone(IntPredicate predicate, int ifNone) voideach(IntProcedure procedure) A synonym for forEach.booleanFollows the same general contract asBag.equals(Object).voidforEachWithOccurrences(IntIntProcedure 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, ObjectIntToObjectFunction<? super T, ? extends T> function) Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.booleanisEmpty()Returns true if this iterable has zero items.intmax()intmin()static IntHashBagnewBag(int size) static IntHashBagstatic IntHashBagnewBag(IntIterable source) static IntHashBagnewBagWith(int... source) newEmpty()Creates a new empty IntHashBag.booleannoneSatisfy(IntPredicate predicate) Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.booleannotEmpty()The English equivalent of !this.isEmpty()intoccurrencesOf(int item) The occurrences of a distinct item in the bag.protected MutableList<IntIntPair> occurrencesSortingBy(int n, IntFunction<IntIntPair> function, MutableList<IntIntPair> returnWhenEmpty) voidreject(IntPredicate predicate) Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.booleanremove(int item) booleanremoveAll(int... source) booleanremoveAll(IntIterable source) booleanremoveIf(IntPredicate predicate) booleanremoveOccurrences(int item, int occurrences) booleanretainAll(int... source) booleanretainAll(IntIterable source) select(IntPredicate predicate) Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.selectByOccurrences(IntPredicate predicate) Returns all elements of the bag that have a number of occurrences that satisfy the predicate.Returns all elements of the bag that have exactly one occurrence.intsize()Returns the number of items in this iterable.intThe size of the Bag when counting only distinct elements.longsum()int[]toArray()Converts the IntIterable to a primitive int array.int[]toArray(int[] array) Converts the IntIterable to a primitive int array.Returns an immutable copy of this bag.protected MutableList<IntIntPair> topOccurrences(int count) Returns thecountmost frequently occurring items.with(int element) with(int element1, int element2) with(int element1, int element2, int element3) withAll(IntIterable iterable) without(int element) withoutAll(IntIterable iterable) voidMethods inherited from class AbstractIntIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface IntBag
toStringOfItemToCountMethods inherited from interface IntIterable
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, toSortedListByMethods inherited from interface MutableIntBag
selectDuplicates, tapMethods inherited from interface PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
items
-
size
private int size
-
-
Constructor Details
-
IntHashBag
public IntHashBag() -
IntHashBag
public IntHashBag(int size) -
IntHashBag
-
IntHashBag
public IntHashBag(int... elements) -
IntHashBag
-
-
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:IntBagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceIntBag
-
clear
public void clear()- Specified by:
clearin interfaceMutableIntCollection
-
with
- Specified by:
within interfaceMutableIntBag- Specified by:
within interfaceMutableIntCollection
-
with
-
with
-
withAll
- Specified by:
withAllin interfaceMutableIntBag- Specified by:
withAllin interfaceMutableIntCollection
-
without
- Specified by:
withoutin interfaceMutableIntBag- Specified by:
withoutin interfaceMutableIntCollection
-
withoutAll
- Specified by:
withoutAllin interfaceMutableIntBag- Specified by:
withoutAllin interfaceMutableIntCollection
-
contains
public boolean contains(int value) Description copied from interface:IntIterableReturns true if the value is contained in the IntIterable, and false if it is not.- Specified by:
containsin interfaceIntIterable
-
occurrencesOf
public int occurrencesOf(int item) Description copied from interface:IntBagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceIntBag
-
forEachWithOccurrences
Description copied from interface:IntBagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceIntBag
-
selectByOccurrences
Description copied from interface:MutableIntBagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceIntBag- Specified by:
selectByOccurrencesin interfaceMutableIntBag
-
selectUnique
Description copied from interface:MutableIntBagReturns all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceIntBag- Specified by:
selectUniquein interfaceMutableIntBag
-
topOccurrences
Description copied from interface:MutableIntBagReturns 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 interfaceIntBag- Specified by:
topOccurrencesin interfaceMutableIntBag
-
bottomOccurrences
Description copied from interface:MutableIntBagReturns 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 interfaceIntBag- Specified by:
bottomOccurrencesin interfaceMutableIntBag
-
occurrencesSortingBy
protected MutableList<IntIntPair> occurrencesSortingBy(int n, IntFunction<IntIntPair> function, MutableList<IntIntPair> returnWhenEmpty) -
toListWithOccurrences
-
add
public boolean add(int item) - Specified by:
addin interfaceMutableIntCollection
-
remove
public boolean remove(int item) - Specified by:
removein interfaceMutableIntCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableIntCollection
-
addAll
public boolean addAll(int... source) - Specified by:
addAllin interfaceMutableIntCollection
-
addAll
- Specified by:
addAllin interfaceMutableIntCollection
-
removeAll
public boolean removeAll(int... source) - Specified by:
removeAllin interfaceMutableIntCollection
-
removeAll
- Specified by:
removeAllin interfaceMutableIntCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableIntCollection- See Also:
-
retainAll
public boolean retainAll(int... source) - Specified by:
retainAllin interfaceMutableIntCollection- See Also:
-
addOccurrences
public void addOccurrences(int item, int occurrences) - Specified by:
addOccurrencesin interfaceMutableIntBag
-
removeOccurrences
public boolean removeOccurrences(int item, int occurrences) - Specified by:
removeOccurrencesin interfaceMutableIntBag
-
each
Description copied from interface:IntIterableA synonym for forEach.- Specified by:
eachin interfaceIntIterable- Since:
- 7.0.
-
select
Description copied from interface:IntIterableReturns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.- Specified by:
selectin interfaceIntBag- Specified by:
selectin interfaceIntIterable- Specified by:
selectin interfaceMutableIntBag- Specified by:
selectin interfaceMutableIntCollection
-
reject
Description copied from interface:IntIterableReturns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.- Specified by:
rejectin interfaceIntBag- Specified by:
rejectin interfaceIntIterable- Specified by:
rejectin interfaceMutableIntBag- Specified by:
rejectin interfaceMutableIntCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectIntToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoin interfaceIntIterable
-
chunk
Description copied from interface:IntIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceIntIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingIntIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
equals
-
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:IntIterableReturns a count of the number of elements in the IntIterable that return true for the specified predicate.- Specified by:
countin interfaceIntIterable
-
anySatisfy
Description copied from interface:IntIterableReturns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceIntIterable
-
allSatisfy
Description copied from interface:IntIterableReturns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceIntIterable
-
noneSatisfy
Description copied from interface:IntIterableReturns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceIntIterable
-
detectIfNone
- Specified by:
detectIfNonein interfaceIntIterable
-
collect
Description copied from interface:IntIterableReturns 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 interfaceIntBag- Specified by:
collectin interfaceIntIterable- Specified by:
collectin interfaceMutableIntBag- Specified by:
collectin interfaceMutableIntCollection
-
max
public int max()- Specified by:
maxin interfaceIntIterable
-
min
public int min()- Specified by:
minin interfaceIntIterable
-
sum
public long sum()- Specified by:
sumin interfaceIntIterable
-
toArray
public int[] toArray()Description copied from interface:IntIterableConverts the IntIterable to a primitive int array.- Specified by:
toArrayin interfaceIntIterable
-
toArray
public int[] toArray(int[] array) Description copied from interface:IntIterableConverts the IntIterable to a primitive int 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 interfaceIntIterable
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableIntBag- Specified by:
asUnmodifiablein interfaceMutableIntCollection
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableIntBag- Specified by:
asSynchronizedin interfaceMutableIntCollection
-
toImmutable
Description copied from interface:MutableIntBagReturns an immutable copy of this bag.- Specified by:
toImmutablein interfaceIntBag- Specified by:
toImmutablein interfaceMutableIntBag- Specified by:
toImmutablein interfaceMutableIntCollection
-
newEmpty
Creates a new empty IntHashBag.- Specified by:
newEmptyin interfaceMutableIntBag- Specified by:
newEmptyin interfaceMutableIntCollection- Since:
- 9.2.
-
intIterator
Description copied from interface:IntIterableReturns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.- Specified by:
intIteratorin interfaceIntIterable- Specified by:
intIteratorin interfaceMutableIntCollection
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-