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:
-
Constructor Summary
ConstructorDescriptionIntHashBag
(int size) IntHashBag
(int... elements) IntHashBag
(IntIterable iterable) IntHashBag
(IntHashBag bag) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int item) boolean
addAll
(int... source) boolean
addAll
(IntIterable source) void
addOccurrences
(int item, int occurrences) boolean
allSatisfy
(IntPredicate predicate) Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy
(IntPredicate predicate) Returns true if any of the elements in the IntIterable 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
.bottomOccurrences
(int count) Returns thecount
least frequently occurring items.chunk
(int size) Partitions elements in fixed size chunks.void
clear()
<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.boolean
contains
(int value) Returns true if the value is contained in the IntIterable, and false if it is not.int
count
(IntPredicate predicate) Returns a count of the number of elements in the IntIterable that return true for the specified predicate.int
detectIfNone
(IntPredicate predicate, int ifNone) void
each
(IntProcedure procedure) A synonym for forEach.boolean
Follows the same general contract asBag.equals(Object)
.void
forEachWithOccurrences
(IntIntProcedure 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, ObjectIntToObjectFunction<? super T, ? extends T> function) Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.boolean
isEmpty()
Returns true if this iterable has zero items.int
max()
int
min()
static IntHashBag
newBag
(int size) static IntHashBag
static IntHashBag
newBag
(IntIterable source) static IntHashBag
newBagWith
(int... source) newEmpty()
Creates a new empty IntHashBag.boolean
noneSatisfy
(IntPredicate predicate) Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.boolean
notEmpty()
The English equivalent of !this.isEmpty()int
occurrencesOf
(int item) The occurrences of a distinct item in the bag.void
reject
(IntPredicate predicate) Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.boolean
remove
(int item) boolean
removeAll
(int... source) boolean
removeAll
(IntIterable source) boolean
removeIf
(IntPredicate predicate) boolean
removeOccurrences
(int item, int occurrences) boolean
retainAll
(int... source) boolean
retainAll
(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.int
size()
Returns the number of items in this iterable.int
The size of the Bag when counting only distinct elements.long
sum()
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.topOccurrences
(int count) Returns thecount
most 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) void
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractIntIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.bag.primitive.IntBag
toStringOfItemToCount
Methods inherited from interface org.eclipse.collections.api.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, toSortedListBy
Methods inherited from interface org.eclipse.collections.api.bag.primitive.MutableIntBag
selectDuplicates, tap
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
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: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:IntBag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceIntBag
-
clear
public void clear()- Specified by:
clear
in interfaceMutableIntCollection
-
with
- Specified by:
with
in interfaceMutableIntBag
- Specified by:
with
in interfaceMutableIntCollection
-
with
-
with
-
withAll
- Specified by:
withAll
in interfaceMutableIntBag
- Specified by:
withAll
in interfaceMutableIntCollection
-
without
- Specified by:
without
in interfaceMutableIntBag
- Specified by:
without
in interfaceMutableIntCollection
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableIntBag
- Specified by:
withoutAll
in interfaceMutableIntCollection
-
contains
public boolean contains(int value) Description copied from interface:IntIterable
Returns true if the value is contained in the IntIterable, and false if it is not.- Specified by:
contains
in interfaceIntIterable
-
occurrencesOf
public int occurrencesOf(int item) Description copied from interface:IntBag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceIntBag
-
forEachWithOccurrences
Description copied from interface:IntBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceIntBag
-
selectByOccurrences
Description copied from interface:MutableIntBag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceIntBag
- Specified by:
selectByOccurrences
in interfaceMutableIntBag
-
selectUnique
Description copied from interface:MutableIntBag
Returns all elements of the bag that have exactly one occurrence.- Specified by:
selectUnique
in interfaceIntBag
- Specified by:
selectUnique
in interfaceMutableIntBag
-
topOccurrences
Description copied from interface:MutableIntBag
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 interfaceIntBag
- Specified by:
topOccurrences
in interfaceMutableIntBag
-
bottomOccurrences
Description copied from interface:MutableIntBag
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 interfaceIntBag
- Specified by:
bottomOccurrences
in interfaceMutableIntBag
-
add
public boolean add(int item) - Specified by:
add
in interfaceMutableIntCollection
-
remove
public boolean remove(int item) - Specified by:
remove
in interfaceMutableIntCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableIntCollection
-
addAll
public boolean addAll(int... source) - Specified by:
addAll
in interfaceMutableIntCollection
-
addAll
- Specified by:
addAll
in interfaceMutableIntCollection
-
removeAll
public boolean removeAll(int... source) - Specified by:
removeAll
in interfaceMutableIntCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableIntCollection
-
retainAll
- Specified by:
retainAll
in interfaceMutableIntCollection
- See Also:
-
retainAll
public boolean retainAll(int... source) - Specified by:
retainAll
in interfaceMutableIntCollection
- See Also:
-
addOccurrences
public void addOccurrences(int item, int occurrences) - Specified by:
addOccurrences
in interfaceMutableIntBag
-
removeOccurrences
public boolean removeOccurrences(int item, int occurrences) - Specified by:
removeOccurrences
in interfaceMutableIntBag
-
each
Description copied from interface:IntIterable
A synonym for forEach.- Specified by:
each
in interfaceIntIterable
- Since:
- 7.0.
-
select
Description copied from interface:IntIterable
Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.- Specified by:
select
in interfaceIntBag
- Specified by:
select
in interfaceIntIterable
- Specified by:
select
in interfaceMutableIntBag
- Specified by:
select
in interfaceMutableIntCollection
-
reject
Description copied from interface:IntIterable
Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.- Specified by:
reject
in interfaceIntBag
- Specified by:
reject
in interfaceIntIterable
- Specified by:
reject
in interfaceMutableIntBag
- Specified by:
reject
in interfaceMutableIntCollection
-
injectInto
- Specified by:
injectInto
in interfaceIntIterable
-
chunk
Description copied from interface:IntIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceIntIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingIntIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
equals
Description copied from interface:IntBag
Follows the same general contract asBag.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:IntBag
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:IntIterable
Returns a count of the number of elements in the IntIterable that return true for the specified predicate.- Specified by:
count
in interfaceIntIterable
-
anySatisfy
Description copied from interface:IntIterable
Returns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceIntIterable
-
allSatisfy
Description copied from interface:IntIterable
Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceIntIterable
-
noneSatisfy
Description copied from interface:IntIterable
Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceIntIterable
-
detectIfNone
- Specified by:
detectIfNone
in interfaceIntIterable
-
collect
Description copied from interface:IntIterable
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 interfaceIntBag
- Specified by:
collect
in interfaceIntIterable
- Specified by:
collect
in interfaceMutableIntBag
- Specified by:
collect
in interfaceMutableIntCollection
-
max
public int max()- Specified by:
max
in interfaceIntIterable
-
min
public int min()- Specified by:
min
in interfaceIntIterable
-
sum
public long sum()- Specified by:
sum
in interfaceIntIterable
-
toArray
public int[] toArray()Description copied from interface:IntIterable
Converts the IntIterable to a primitive int array.- Specified by:
toArray
in interfaceIntIterable
-
toArray
public int[] toArray(int[] array) Description copied from interface:IntIterable
Converts 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:
toArray
in interfaceIntIterable
-
asUnmodifiable
- Specified by:
asUnmodifiable
in interfaceMutableIntBag
- Specified by:
asUnmodifiable
in interfaceMutableIntCollection
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableIntBag
- Specified by:
asSynchronized
in interfaceMutableIntCollection
-
toImmutable
Description copied from interface:MutableIntBag
Returns an immutable copy of this bag.- Specified by:
toImmutable
in interfaceIntBag
- Specified by:
toImmutable
in interfaceMutableIntBag
- Specified by:
toImmutable
in interfaceMutableIntCollection
-
newEmpty
Creates a new empty IntHashBag.- Specified by:
newEmpty
in interfaceMutableIntBag
- Specified by:
newEmpty
in interfaceMutableIntCollection
- Since:
- 9.2.
-
intIterator
Description copied from interface:IntIterable
Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.- Specified by:
intIterator
in interfaceIntIterable
- Specified by:
intIterator
in interfaceMutableIntCollection
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-