Class ByteHashBag
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractByteIterable
-
- org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,ByteBag
,MutableByteBag
,ByteIterable
,MutableByteCollection
,PrimitiveIterable
public class ByteHashBag extends AbstractByteIterable implements MutableByteBag, java.io.Externalizable
ByteHashBag is similar toHashBag
, and is memory-optimized for byte 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 class
ByteHashBag.InternalIterator
-
Field Summary
Fields Modifier and Type Field Description private ByteIntHashMap
items
private static long
serialVersionUID
private int
size
-
Constructor Summary
Constructors Constructor Description ByteHashBag()
ByteHashBag(byte... elements)
ByteHashBag(int size)
ByteHashBag(ByteIterable iterable)
ByteHashBag(ByteHashBag bag)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(byte item)
boolean
addAll(byte... source)
boolean
addAll(ByteIterable source)
void
addOccurrences(byte item, int occurrences)
boolean
allSatisfy(BytePredicate predicate)
Returns true if all of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(BytePredicate predicate)
Returns true if any of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.void
appendString(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
.MutableByteBag
asSynchronized()
MutableByteBag
asUnmodifiable()
MutableList<ByteIntPair>
bottomOccurrences(int count)
Returns thecount
least frequently occurring items.MutableByteIterator
byteIterator()
Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.RichIterable<ByteIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableBag<V>
collect(ByteToObjectFunction<? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source collection.boolean
contains(byte value)
Returns true if the value is contained in the ByteIterable, and false if it is not.int
count(BytePredicate predicate)
Returns a count of the number of elements in the ByteIterable that return true for the specified predicate.byte
detectIfNone(BytePredicate predicate, byte ifNone)
void
each(ByteProcedure procedure)
A synonym for forEach.boolean
equals(java.lang.Object otherBag)
Follows the same general contract asBag.equals(Object)
.void
forEachWithOccurrences(ByteIntProcedure 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, ObjectByteToObjectFunction<? super T,? extends T> function)
boolean
isEmpty()
Returns true if this iterable has zero items.byte
max()
byte
min()
static ByteHashBag
newBag(int size)
static ByteHashBag
newBag(ByteBag source)
static ByteHashBag
newBag(ByteIterable source)
static ByteHashBag
newBagWith(byte... source)
ByteHashBag
newEmpty()
Creates a new empty ByteHashBag.boolean
noneSatisfy(BytePredicate predicate)
Returns true if none of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.boolean
notEmpty()
The English equivalent of !this.isEmpty()int
occurrencesOf(byte item)
The occurrences of a distinct item in the bag.protected MutableList<ByteIntPair>
occurrencesSortingBy(int n, IntFunction<ByteIntPair> function, MutableList<ByteIntPair> returnWhenEmpty)
void
readExternal(java.io.ObjectInput in)
ByteHashBag
reject(BytePredicate predicate)
Returns a new ByteIterable with all of the elements in the ByteIterable that return false for the specified predicate.boolean
remove(byte item)
boolean
removeAll(byte... source)
boolean
removeAll(ByteIterable source)
boolean
removeIf(BytePredicate predicate)
boolean
removeOccurrences(byte item, int occurrences)
boolean
retainAll(byte... source)
boolean
retainAll(ByteIterable source)
ByteHashBag
select(BytePredicate predicate)
Returns a new ByteIterable with all of the elements in the ByteIterable that return true for the specified predicate.ByteHashBag
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableByteSet
selectUnique()
Returns all elements of the bag that have exactly one occurrence.int
size()
Returns the number of items in this iterable.int
sizeDistinct()
The size of the Bag when counting only distinct elements.long
sum()
byte[]
toArray()
Converts the ByteIterable to a primitive byte array.byte[]
toArray(byte[] array)
Converts the ByteIterable to a primitive byte array.ImmutableByteBag
toImmutable()
Returns an immutable copy of this bag.protected MutableList<ByteIntPair>
toListWithOccurrences()
MutableList<ByteIntPair>
topOccurrences(int count)
Returns thecount
most frequently occurring items.ByteHashBag
with(byte element)
ByteHashBag
with(byte element1, byte element2)
ByteHashBag
with(byte element1, byte element2, byte element3)
ByteHashBag
withAll(ByteIterable iterable)
ByteHashBag
without(byte element)
ByteHashBag
withoutAll(ByteIterable iterable)
void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractByteIterable
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.ByteBag
toStringOfItemToCount
-
Methods inherited from interface org.eclipse.collections.api.ByteIterable
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.MutableByteBag
selectDuplicates, tap
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
items
private ByteIntHashMap items
-
size
private int size
-
-
Constructor Detail
-
ByteHashBag
public ByteHashBag()
-
ByteHashBag
public ByteHashBag(int size)
-
ByteHashBag
public ByteHashBag(ByteIterable iterable)
-
ByteHashBag
public ByteHashBag(byte... elements)
-
ByteHashBag
public ByteHashBag(ByteHashBag bag)
-
-
Method Detail
-
newBag
public static ByteHashBag newBag(int size)
-
newBagWith
public static ByteHashBag newBagWith(byte... source)
-
newBag
public static ByteHashBag newBag(ByteIterable source)
-
newBag
public static ByteHashBag newBag(ByteBag source)
-
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:ByteBag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceByteBag
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableByteCollection
-
with
public ByteHashBag with(byte element)
- Specified by:
with
in interfaceMutableByteBag
- Specified by:
with
in interfaceMutableByteCollection
-
with
public ByteHashBag with(byte element1, byte element2)
-
with
public ByteHashBag with(byte element1, byte element2, byte element3)
-
withAll
public ByteHashBag withAll(ByteIterable iterable)
- Specified by:
withAll
in interfaceMutableByteBag
- Specified by:
withAll
in interfaceMutableByteCollection
-
without
public ByteHashBag without(byte element)
- Specified by:
without
in interfaceMutableByteBag
- Specified by:
without
in interfaceMutableByteCollection
-
withoutAll
public ByteHashBag withoutAll(ByteIterable iterable)
- Specified by:
withoutAll
in interfaceMutableByteBag
- Specified by:
withoutAll
in interfaceMutableByteCollection
-
contains
public boolean contains(byte value)
Description copied from interface:ByteIterable
Returns true if the value is contained in the ByteIterable, and false if it is not.- Specified by:
contains
in interfaceByteIterable
-
occurrencesOf
public int occurrencesOf(byte item)
Description copied from interface:ByteBag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceByteBag
-
forEachWithOccurrences
public void forEachWithOccurrences(ByteIntProcedure procedure)
Description copied from interface:ByteBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceByteBag
-
selectByOccurrences
public ByteHashBag selectByOccurrences(IntPredicate predicate)
Description copied from interface:MutableByteBag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceByteBag
- Specified by:
selectByOccurrences
in interfaceMutableByteBag
-
selectUnique
public MutableByteSet selectUnique()
Description copied from interface:MutableByteBag
Returns all elements of the bag that have exactly one occurrence.- Specified by:
selectUnique
in interfaceByteBag
- Specified by:
selectUnique
in interfaceMutableByteBag
-
topOccurrences
public MutableList<ByteIntPair> topOccurrences(int count)
Description copied from interface:MutableByteBag
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 interfaceByteBag
- Specified by:
topOccurrences
in interfaceMutableByteBag
-
bottomOccurrences
public MutableList<ByteIntPair> bottomOccurrences(int count)
Description copied from interface:MutableByteBag
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 interfaceByteBag
- Specified by:
bottomOccurrences
in interfaceMutableByteBag
-
occurrencesSortingBy
protected MutableList<ByteIntPair> occurrencesSortingBy(int n, IntFunction<ByteIntPair> function, MutableList<ByteIntPair> returnWhenEmpty)
-
toListWithOccurrences
protected MutableList<ByteIntPair> toListWithOccurrences()
-
add
public boolean add(byte item)
- Specified by:
add
in interfaceMutableByteCollection
-
remove
public boolean remove(byte item)
- Specified by:
remove
in interfaceMutableByteCollection
-
removeIf
public boolean removeIf(BytePredicate predicate)
- Specified by:
removeIf
in interfaceMutableByteCollection
-
addAll
public boolean addAll(byte... source)
- Specified by:
addAll
in interfaceMutableByteCollection
-
addAll
public boolean addAll(ByteIterable source)
- Specified by:
addAll
in interfaceMutableByteCollection
-
removeAll
public boolean removeAll(byte... source)
- Specified by:
removeAll
in interfaceMutableByteCollection
-
removeAll
public boolean removeAll(ByteIterable source)
- Specified by:
removeAll
in interfaceMutableByteCollection
-
retainAll
public boolean retainAll(ByteIterable source)
- Specified by:
retainAll
in interfaceMutableByteCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(byte... source)
- Specified by:
retainAll
in interfaceMutableByteCollection
- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(byte item, int occurrences)
- Specified by:
addOccurrences
in interfaceMutableByteBag
-
removeOccurrences
public boolean removeOccurrences(byte item, int occurrences)
- Specified by:
removeOccurrences
in interfaceMutableByteBag
-
each
public void each(ByteProcedure procedure)
Description copied from interface:ByteIterable
A synonym for forEach.- Specified by:
each
in interfaceByteIterable
- Since:
- 7.0.
-
select
public ByteHashBag select(BytePredicate predicate)
Description copied from interface:ByteIterable
Returns a new ByteIterable with all of the elements in the ByteIterable that return true for the specified predicate.- Specified by:
select
in interfaceByteBag
- Specified by:
select
in interfaceByteIterable
- Specified by:
select
in interfaceMutableByteBag
- Specified by:
select
in interfaceMutableByteCollection
-
reject
public ByteHashBag reject(BytePredicate predicate)
Description copied from interface:ByteIterable
Returns a new ByteIterable with all of the elements in the ByteIterable that return false for the specified predicate.- Specified by:
reject
in interfaceByteBag
- Specified by:
reject
in interfaceByteIterable
- Specified by:
reject
in interfaceMutableByteBag
- Specified by:
reject
in interfaceMutableByteCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectByteToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceByteIterable
-
chunk
public RichIterable<ByteIterable> chunk(int size)
Description copied from interface:ByteIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceByteIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingByteIterable
s 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:ByteBag
Follows the same general contract asBag.equals(Object)
.
-
hashCode
public int hashCode()
Description copied from interface:ByteBag
Follows 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: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
public int count(BytePredicate predicate)
Description copied from interface:ByteIterable
Returns a count of the number of elements in the ByteIterable that return true for the specified predicate.- Specified by:
count
in interfaceByteIterable
-
anySatisfy
public boolean anySatisfy(BytePredicate predicate)
Description copied from interface:ByteIterable
Returns true if any of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceByteIterable
-
allSatisfy
public boolean allSatisfy(BytePredicate predicate)
Description copied from interface:ByteIterable
Returns true if all of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceByteIterable
-
noneSatisfy
public boolean noneSatisfy(BytePredicate predicate)
Description copied from interface:ByteIterable
Returns true if none of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceByteIterable
-
detectIfNone
public byte detectIfNone(BytePredicate predicate, byte ifNone)
- Specified by:
detectIfNone
in interfaceByteIterable
-
collect
public <V> MutableBag<V> collect(ByteToObjectFunction<? extends V> function)
Description copied from interface:ByteIterable
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 interfaceByteBag
- Specified by:
collect
in interfaceByteIterable
- Specified by:
collect
in interfaceMutableByteBag
- Specified by:
collect
in interfaceMutableByteCollection
-
max
public byte max()
- Specified by:
max
in interfaceByteIterable
-
min
public byte min()
- Specified by:
min
in interfaceByteIterable
-
sum
public long sum()
- Specified by:
sum
in interfaceByteIterable
-
toArray
public byte[] toArray()
Description copied from interface:ByteIterable
Converts the ByteIterable to a primitive byte array.- Specified by:
toArray
in interfaceByteIterable
-
toArray
public byte[] toArray(byte[] array)
Description copied from interface:ByteIterable
Converts the ByteIterable to a primitive byte 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 interfaceByteIterable
-
asUnmodifiable
public MutableByteBag asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableByteBag
- Specified by:
asUnmodifiable
in interfaceMutableByteCollection
-
asSynchronized
public MutableByteBag asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableByteBag
- Specified by:
asSynchronized
in interfaceMutableByteCollection
-
toImmutable
public ImmutableByteBag toImmutable()
Description copied from interface:MutableByteBag
Returns an immutable copy of this bag.- Specified by:
toImmutable
in interfaceByteBag
- Specified by:
toImmutable
in interfaceMutableByteBag
- Specified by:
toImmutable
in interfaceMutableByteCollection
-
newEmpty
public ByteHashBag newEmpty()
Creates a new empty ByteHashBag.- Specified by:
newEmpty
in interfaceMutableByteBag
- Specified by:
newEmpty
in interfaceMutableByteCollection
- Since:
- 9.2.
-
byteIterator
public MutableByteIterator byteIterator()
Description copied from interface:ByteIterable
Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.- Specified by:
byteIterator
in interfaceByteIterable
- Specified by:
byteIterator
in interfaceMutableByteCollection
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
-