Class ByteHashBag
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractByteIterable
org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag
- All Implemented Interfaces:
Externalizable
,Serializable
,ByteBag
,MutableByteBag
,ByteIterable
,MutableByteCollection
,PrimitiveIterable
public class ByteHashBag extends AbstractByteIterable implements MutableByteBag, Externalizable
ByteHashBag is similar to
HashBag
, and is memory-optimized for byte primitives.
This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description ByteHashBag()
ByteHashBag(byte... elements)
ByteHashBag(int size)
ByteHashBag(ByteIterable iterable)
ByteHashBag(ByteHashBag bag)
-
Method Summary
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(Appendable appendable, String start, String separator, 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(Object otherBag)
Follows the same general contract asBag.equals(Object)
.void
forEach(ByteProcedure procedure)
Applies the ByteProcedure to each element in the ByteIterable.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.void
readExternal(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.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(ObjectOutput out)
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractByteIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
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, flatCollect, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList
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
-
Constructor Details
-
ByteHashBag
public ByteHashBag() -
ByteHashBag
public ByteHashBag(int size) -
ByteHashBag
-
ByteHashBag
public ByteHashBag(byte... elements) -
ByteHashBag
-
-
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: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
- Specified by:
with
in interfaceMutableByteBag
- Specified by:
with
in interfaceMutableByteCollection
-
with
-
with
-
withAll
- Specified by:
withAll
in interfaceMutableByteBag
- Specified by:
withAll
in interfaceMutableByteCollection
-
without
- Specified by:
without
in interfaceMutableByteBag
- Specified by:
without
in interfaceMutableByteCollection
-
withoutAll
- 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
Description copied from interface:ByteBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceByteBag
-
selectByOccurrences
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
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
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
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
-
add
public boolean add(byte item)- Specified by:
add
in interfaceMutableByteCollection
-
remove
public boolean remove(byte item)- Specified by:
remove
in interfaceMutableByteCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableByteCollection
-
addAll
public boolean addAll(byte... source)- Specified by:
addAll
in interfaceMutableByteCollection
-
addAll
- Specified by:
addAll
in interfaceMutableByteCollection
-
removeAll
public boolean removeAll(byte... source)- Specified by:
removeAll
in interfaceMutableByteCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableByteCollection
-
retainAll
- 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
-
forEach
Description copied from interface:ByteIterable
Applies the ByteProcedure to each element in the ByteIterable.- Specified by:
forEach
in interfaceByteIterable
-
each
Description copied from interface:ByteIterable
A synonym for forEach.- Specified by:
each
in interfaceByteIterable
- Since:
- 7.0.
-
select
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
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
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
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
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: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
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
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
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
- Specified by:
detectIfNone
in interfaceByteIterable
-
collect
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
- Specified by:
asUnmodifiable
in interfaceMutableByteBag
- Specified by:
asUnmodifiable
in interfaceMutableByteCollection
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableByteBag
- Specified by:
asSynchronized
in interfaceMutableByteCollection
-
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
Creates a new empty ByteHashBag.- Specified by:
newEmpty
in interfaceMutableByteBag
- Specified by:
newEmpty
in interfaceMutableByteCollection
- Since:
- 9.2.
-
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
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-