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