Class ShortHashBag
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractShortIterable
-
- org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,MutableShortBag,ShortBag,MutableShortCollection,PrimitiveIterable,ShortIterable
public class ShortHashBag extends AbstractShortIterable implements MutableShortBag, java.io.Externalizable
ShortHashBag is similar toHashBag, and is memory-optimized for short primitives. This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classShortHashBag.InternalIterator
-
Field Summary
Fields Modifier and Type Field Description private ShortIntHashMapitemsprivate static longserialVersionUIDprivate intsize
-
Constructor Summary
Constructors Constructor Description ShortHashBag()ShortHashBag(int size)ShortHashBag(short... elements)ShortHashBag(ShortIterable iterable)ShortHashBag(ShortHashBag bag)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(short item)booleanaddAll(short... source)booleanaddAll(ShortIterable source)voidaddOccurrences(short item, int occurrences)booleanallSatisfy(ShortPredicate predicate)Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(ShortPredicate predicate)Returns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.voidappendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Prints a string representation of this collection onto the givenAppendable.MutableShortBagasSynchronized()MutableShortBagasUnmodifiable()MutableList<ShortIntPair>bottomOccurrences(int count)Returns thecountleast frequently occurring items.RichIterable<ShortIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<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.booleancontains(short value)Returns true if the value is contained in the ShortIterable, and false if it is not.intcount(ShortPredicate predicate)Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.shortdetectIfNone(ShortPredicate predicate, short ifNone)voideach(ShortProcedure procedure)A synonym for forEach.booleanequals(java.lang.Object otherBag)Follows the same general contract asBag.equals(Object).voidforEachWithOccurrences(ShortIntProcedure 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, ObjectShortToObjectFunction<? super T,? extends T> function)booleanisEmpty()Returns true if this iterable has zero items.shortmax()shortmin()static ShortHashBagnewBag(int size)static ShortHashBagnewBag(ShortBag source)static ShortHashBagnewBag(ShortIterable source)static ShortHashBagnewBagWith(short... source)ShortHashBagnewEmpty()Creates a new empty ShortHashBag.booleannoneSatisfy(ShortPredicate predicate)Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.booleannotEmpty()The English equivalent of !this.isEmpty()intoccurrencesOf(short item)The occurrences of a distinct item in the bag.protected MutableList<ShortIntPair>occurrencesSortingBy(int n, IntFunction<ShortIntPair> function, MutableList<ShortIntPair> returnWhenEmpty)voidreadExternal(java.io.ObjectInput in)ShortHashBagreject(ShortPredicate predicate)Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.booleanremove(short item)booleanremoveAll(short... source)booleanremoveAll(ShortIterable source)booleanremoveIf(ShortPredicate predicate)booleanremoveOccurrences(short item, int occurrences)booleanretainAll(short... source)booleanretainAll(ShortIterable source)ShortHashBagselect(ShortPredicate predicate)Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.ShortHashBagselectByOccurrences(IntPredicate predicate)Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableShortSetselectUnique()Returns all elements of the bag that have exactly one occurrence.MutableShortIteratorshortIterator()Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.intsize()Returns the number of items in this iterable.intsizeDistinct()The size of the Bag when counting only distinct elements.longsum()short[]toArray()Converts the ShortIterable to a primitive short array.short[]toArray(short[] array)Converts the ShortIterable to a primitive short array.ImmutableShortBagtoImmutable()Returns an immutable copy of this bag.protected MutableList<ShortIntPair>toListWithOccurrences()MutableList<ShortIntPair>topOccurrences(int count)Returns thecountmost frequently occurring items.ShortHashBagwith(short element)ShortHashBagwith(short element1, short element2)ShortHashBagwith(short element1, short element2, short element3)ShortHashBagwithAll(ShortIterable iterable)ShortHashBagwithout(short element)ShortHashBagwithoutAll(ShortIterable iterable)voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractShortIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
items
private ShortIntHashMap items
-
size
private int size
-
-
Constructor Detail
-
ShortHashBag
public ShortHashBag()
-
ShortHashBag
public ShortHashBag(int size)
-
ShortHashBag
public ShortHashBag(ShortIterable iterable)
-
ShortHashBag
public ShortHashBag(short... elements)
-
ShortHashBag
public ShortHashBag(ShortHashBag bag)
-
-
Method Detail
-
newBag
public static ShortHashBag newBag(int size)
-
newBagWith
public static ShortHashBag newBagWith(short... source)
-
newBag
public static ShortHashBag newBag(ShortIterable source)
-
newBag
public static ShortHashBag newBag(ShortBag source)
-
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:ShortBagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceShortBag
-
clear
public void clear()
- Specified by:
clearin interfaceMutableShortCollection
-
with
public ShortHashBag with(short element)
- Specified by:
within interfaceMutableShortBag- Specified by:
within interfaceMutableShortCollection
-
with
public ShortHashBag with(short element1, short element2)
-
with
public ShortHashBag with(short element1, short element2, short element3)
-
withAll
public ShortHashBag withAll(ShortIterable iterable)
- Specified by:
withAllin interfaceMutableShortBag- Specified by:
withAllin interfaceMutableShortCollection
-
without
public ShortHashBag without(short element)
- Specified by:
withoutin interfaceMutableShortBag- Specified by:
withoutin interfaceMutableShortCollection
-
withoutAll
public ShortHashBag withoutAll(ShortIterable iterable)
- Specified by:
withoutAllin interfaceMutableShortBag- Specified by:
withoutAllin interfaceMutableShortCollection
-
contains
public boolean contains(short value)
Description copied from interface:ShortIterableReturns true if the value is contained in the ShortIterable, and false if it is not.- Specified by:
containsin interfaceShortIterable
-
occurrencesOf
public int occurrencesOf(short item)
Description copied from interface:ShortBagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceShortBag
-
forEachWithOccurrences
public void forEachWithOccurrences(ShortIntProcedure procedure)
Description copied from interface:ShortBagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceShortBag
-
selectByOccurrences
public ShortHashBag selectByOccurrences(IntPredicate predicate)
Description copied from interface:MutableShortBagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceMutableShortBag- Specified by:
selectByOccurrencesin interfaceShortBag
-
selectUnique
public MutableShortSet selectUnique()
Description copied from interface:MutableShortBagReturns all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceMutableShortBag- Specified by:
selectUniquein interfaceShortBag
-
topOccurrences
public MutableList<ShortIntPair> topOccurrences(int count)
Description copied from interface:MutableShortBagReturns 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 interfaceMutableShortBag- Specified by:
topOccurrencesin interfaceShortBag
-
bottomOccurrences
public MutableList<ShortIntPair> bottomOccurrences(int count)
Description copied from interface:MutableShortBagReturns 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 interfaceMutableShortBag- Specified by:
bottomOccurrencesin interfaceShortBag
-
occurrencesSortingBy
protected MutableList<ShortIntPair> occurrencesSortingBy(int n, IntFunction<ShortIntPair> function, MutableList<ShortIntPair> returnWhenEmpty)
-
toListWithOccurrences
protected MutableList<ShortIntPair> toListWithOccurrences()
-
add
public boolean add(short item)
- Specified by:
addin interfaceMutableShortCollection
-
remove
public boolean remove(short item)
- Specified by:
removein interfaceMutableShortCollection
-
removeIf
public boolean removeIf(ShortPredicate predicate)
- Specified by:
removeIfin interfaceMutableShortCollection
-
addAll
public boolean addAll(short... source)
- Specified by:
addAllin interfaceMutableShortCollection
-
addAll
public boolean addAll(ShortIterable source)
- Specified by:
addAllin interfaceMutableShortCollection
-
removeAll
public boolean removeAll(short... source)
- Specified by:
removeAllin interfaceMutableShortCollection
-
removeAll
public boolean removeAll(ShortIterable source)
- Specified by:
removeAllin interfaceMutableShortCollection
-
retainAll
public boolean retainAll(ShortIterable source)
- Specified by:
retainAllin interfaceMutableShortCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(short... source)
- Specified by:
retainAllin interfaceMutableShortCollection- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(short item, int occurrences)- Specified by:
addOccurrencesin interfaceMutableShortBag
-
removeOccurrences
public boolean removeOccurrences(short item, int occurrences)- Specified by:
removeOccurrencesin interfaceMutableShortBag
-
each
public void each(ShortProcedure procedure)
Description copied from interface:ShortIterableA synonym for forEach.- Specified by:
eachin interfaceShortIterable- Since:
- 7.0.
-
select
public ShortHashBag select(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.- Specified by:
selectin interfaceMutableShortBag- Specified by:
selectin interfaceMutableShortCollection- Specified by:
selectin interfaceShortBag- Specified by:
selectin interfaceShortIterable
-
reject
public ShortHashBag reject(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.- Specified by:
rejectin interfaceMutableShortBag- Specified by:
rejectin interfaceMutableShortCollection- Specified by:
rejectin interfaceShortBag- Specified by:
rejectin interfaceShortIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceShortIterable
-
chunk
public RichIterable<ShortIterable> chunk(int size)
Description copied from interface:ShortIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceShortIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingShortIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
equals
public boolean equals(java.lang.Object otherBag)
Description copied from interface:ShortBagFollows the same general contract asBag.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:ShortBagFollows the same general contract asBag.hashCode().
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)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
public int count(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns a count of the number of elements in the ShortIterable that return true for the specified predicate.- Specified by:
countin interfaceShortIterable
-
anySatisfy
public boolean anySatisfy(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceShortIterable
-
allSatisfy
public boolean allSatisfy(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceShortIterable
-
noneSatisfy
public boolean noneSatisfy(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceShortIterable
-
detectIfNone
public short detectIfNone(ShortPredicate predicate, short ifNone)
- Specified by:
detectIfNonein interfaceShortIterable
-
collect
public <V> MutableBag<V> collect(ShortToObjectFunction<? extends V> function)
Description copied from interface:ShortIterableReturns 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 interfaceMutableShortBag- Specified by:
collectin interfaceMutableShortCollection- Specified by:
collectin interfaceShortBag- Specified by:
collectin interfaceShortIterable
-
max
public short max()
- Specified by:
maxin interfaceShortIterable
-
min
public short min()
- Specified by:
minin interfaceShortIterable
-
sum
public long sum()
- Specified by:
sumin interfaceShortIterable
-
toArray
public short[] toArray()
Description copied from interface:ShortIterableConverts the ShortIterable to a primitive short array.- Specified by:
toArrayin interfaceShortIterable
-
toArray
public short[] toArray(short[] array)
Description copied from interface:ShortIterableConverts 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:
toArrayin interfaceShortIterable
-
asUnmodifiable
public MutableShortBag asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableShortBag- Specified by:
asUnmodifiablein interfaceMutableShortCollection
-
asSynchronized
public MutableShortBag asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableShortBag- Specified by:
asSynchronizedin interfaceMutableShortCollection
-
toImmutable
public ImmutableShortBag toImmutable()
Description copied from interface:MutableShortBagReturns an immutable copy of this bag.- Specified by:
toImmutablein interfaceMutableShortBag- Specified by:
toImmutablein interfaceMutableShortCollection- Specified by:
toImmutablein interfaceShortBag
-
newEmpty
public ShortHashBag newEmpty()
Creates a new empty ShortHashBag.- Specified by:
newEmptyin interfaceMutableShortBag- Specified by:
newEmptyin interfaceMutableShortCollection- Since:
- 9.2.
-
shortIterator
public MutableShortIterator shortIterator()
Description copied from interface:ShortIterableReturns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.- Specified by:
shortIteratorin interfaceMutableShortCollection- Specified by:
shortIteratorin interfaceShortIterable
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
-