Class ByteHashSet
- java.lang.Object
-
- org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,ByteIterable
,MutableByteCollection
,PrimitiveIterable
,ByteSet
,MutableByteSet
public final class ByteHashSet extends java.lang.Object implements MutableByteSet, java.io.Externalizable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ByteHashSet.ImmutableByteHashSet
private class
ByteHashSet.MutableInternalByteIterator
-
Field Summary
Fields Modifier and Type Field Description private long
bitGroup1
private long
bitGroup2
private long
bitGroup3
private long
bitGroup4
private static byte
MAX_BYTE_GROUP_1
private static byte
MAX_BYTE_GROUP_2
private static byte
MAX_BYTE_GROUP_3
private static long
serialVersionUID
private short
size
-
Constructor Summary
Constructors Constructor Description ByteHashSet()
ByteHashSet(byte... elements)
ByteHashSet(int initialCapacity)
Deprecated.since 5.0.ByteHashSet(ByteHashSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(byte element)
boolean
addAll(byte... source)
boolean
addAll(ByteIterable source)
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)
Prints a string representation of this collection onto the givenAppendable
.void
appendString(java.lang.Appendable appendable, java.lang.String separator)
Prints a string representation of this collection onto the givenAppendable
.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
.LazyByteIterable
asLazy()
Returns a LazyByteIterable adapter wrapping the source ByteIterable.MutableByteSet
asSynchronized()
MutableByteSet
asUnmodifiable()
double
average()
MutableByteIterator
byteIterator()
Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.LazyIterable<ByteBytePair>
cartesianProduct(ByteSet set)
Returns the set whose members are all possible ordered pairs (a, b) where a is a member ofthis
and b is a member ofset
.RichIterable<ByteIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableSet<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.boolean
containsAll(byte... source)
Returns true if all of the values specified in the source array are contained in the ByteIterable, and false if they are not.boolean
containsAll(ByteIterable source)
Returns true if all of the values specified in the source ByteIterable are contained in the ByteIterable, and false if they are 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 obj)
Follows the same general contract asSet.equals(Object)
.void
forEach(ByteProcedure procedure)
Applies the ByteProcedure to each element in the ByteIterable.ByteSet
freeze()
Returns a frozen copy of this set.int
hashCode()
Follows the same general contract asSet.hashCode()
.<T> T
injectInto(T injectedValue, ObjectByteToObjectFunction<? super T,? extends T> function)
boolean
isEmpty()
Returns true if this iterable has zero items.java.lang.String
makeString()
Returns a string representation of this collection by delegating toPrimitiveIterable.makeString(String)
and defaulting the separator parameter to the characters", "
(comma and space).java.lang.String
makeString(java.lang.String separator)
Returns a string representation of this collection by delegating toPrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to""
(the empty String).java.lang.String
makeString(java.lang.String start, java.lang.String separator, java.lang.String end)
Returns a string representation of this collection with the elements separated by the specified separator and enclosed between the start and end strings.byte
max()
byte
maxIfEmpty(byte defaultValue)
double
median()
byte
min()
byte
minIfEmpty(byte defaultValue)
ByteHashSet
newEmpty()
Creates a new empty mutable version of the same Set type.static ByteHashSet
newSet(ByteIterable source)
static ByteHashSet
newSetWith(byte... source)
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()void
readExternal(java.io.ObjectInput in)
MutableByteSet
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 value)
boolean
removeAll(byte... source)
boolean
removeAll(ByteIterable source)
boolean
retainAll(byte... source)
boolean
retainAll(ByteIterable source)
ByteHashSet
select(BytePredicate predicate)
Returns a new ByteIterable with all of the elements in the ByteIterable that return true for the specified predicate.int
size()
Returns the number of items in this iterable.long
sum()
byte[]
toArray()
Converts the ByteIterable to a primitive byte array.byte[]
toArray(byte[] array)
Converts the ByteIterable to a primitive byte array.MutableByteBag
toBag()
Converts the ByteIterable to a new MutableByteBag.ImmutableByteSet
toImmutable()
Returns an immutable copy of this set.MutableByteList
toList()
Converts the ByteIterable to a new MutableByteList.MutableByteSet
toSet()
Converts the ByteIterable to a new MutableByteSet.byte[]
toSortedArray()
MutableByteList
toSortedList()
java.lang.String
toString()
Returns a string with the elements of this iterable separated by commas with spaces and enclosed in square brackets.ByteHashSet
with(byte element)
ByteHashSet
withAll(ByteIterable elements)
ByteHashSet
without(byte element)
ByteHashSet
withoutAll(ByteIterable elements)
void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.ByteIterable
averageIfEmpty, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAny, containsAny, containsNone, containsNone, flatCollect, injectIntoBoolean, injectIntoByte, injectIntoChar, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, injectIntoShort, medianIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatistics, toSortedList, toSortedListBy, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.ByteSet
isProperSubsetOf, isSubsetOf
-
Methods inherited from interface org.eclipse.collections.api.collection.primitive.MutableByteCollection
removeIf
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.MutableByteSet
difference, intersect, symmetricDifference, tap, union
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
MAX_BYTE_GROUP_1
private static final byte MAX_BYTE_GROUP_1
- See Also:
- Constant Field Values
-
MAX_BYTE_GROUP_2
private static final byte MAX_BYTE_GROUP_2
- See Also:
- Constant Field Values
-
MAX_BYTE_GROUP_3
private static final byte MAX_BYTE_GROUP_3
- See Also:
- Constant Field Values
-
bitGroup1
private long bitGroup1
-
bitGroup2
private long bitGroup2
-
bitGroup3
private long bitGroup3
-
bitGroup4
private long bitGroup4
-
size
private short size
-
-
Constructor Detail
-
ByteHashSet
public ByteHashSet()
-
ByteHashSet
@Deprecated public ByteHashSet(int initialCapacity)
Deprecated.since 5.0.UseByteHashSet()
instead.
-
ByteHashSet
public ByteHashSet(ByteHashSet set)
-
ByteHashSet
public ByteHashSet(byte... elements)
-
-
Method Detail
-
newSet
public static ByteHashSet newSet(ByteIterable source)
-
newSetWith
public static ByteHashSet newSetWith(byte... source)
-
add
public boolean add(byte element)
- Specified by:
add
in interfaceMutableByteCollection
-
remove
public boolean remove(byte value)
- Specified by:
remove
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
-
cartesianProduct
public LazyIterable<ByteBytePair> cartesianProduct(ByteSet set)
Description copied from interface:ByteSet
Returns the set whose members are all possible ordered pairs (a, b) where a is a member ofthis
and b is a member ofset
.- Specified by:
cartesianProduct
in interfaceByteSet
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:ByteSet
Follows the same general contract asSet.equals(Object)
.
-
hashCode
public int hashCode()
Description copied from interface:ByteSet
Follows the same general contract asSet.hashCode()
.
-
toString
public java.lang.String toString()
Description copied from interface:PrimitiveIterable
Returns a string with the elements of this iterable separated by commas with spaces and enclosed in square brackets.Assert.assertEquals("[]", IntLists.mutable.empty().toString()); Assert.assertEquals("[1]", IntLists.mutable.with(1).toString()); Assert.assertEquals("[1, 2, 3]", IntLists.mutable.with(1, 2, 3).toString());
- Specified by:
toString
in interfacePrimitiveIterable
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this PrimitiveIterable
- See Also:
AbstractCollection.toString()
-
size
public int size()
Description copied from interface:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
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
-
makeString
public java.lang.String makeString()
Description copied from interface:PrimitiveIterable
Returns a string representation of this collection by delegating toPrimitiveIterable.makeString(String)
and defaulting the separator parameter to the characters", "
(comma and space).- Specified by:
makeString
in interfacePrimitiveIterable
- Returns:
- a string representation of this collection.
-
makeString
public java.lang.String makeString(java.lang.String separator)
Description copied from interface:PrimitiveIterable
Returns a string representation of this collection by delegating toPrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to""
(the empty String).- Specified by:
makeString
in interfacePrimitiveIterable
- Returns:
- a string representation of this collection.
-
makeString
public java.lang.String makeString(java.lang.String start, java.lang.String separator, java.lang.String end)
Description copied from interface:PrimitiveIterable
Returns a string representation of this collection with the elements separated by the specified separator and enclosed between the start and end strings.- Specified by:
makeString
in interfacePrimitiveIterable
- Returns:
- a string representation of this collection.
-
appendString
public void appendString(java.lang.Appendable appendable)
Description copied from interface:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString()
.- Specified by:
appendString
in interfacePrimitiveIterable
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String separator)
Description copied from interface:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString(String)
.- Specified by:
appendString
in interfacePrimitiveIterable
-
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
-
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(ByteIterable source)
- Specified by:
removeAll
in interfaceMutableByteCollection
-
removeAll
public boolean removeAll(byte... 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)
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableByteCollection
-
with
public ByteHashSet with(byte element)
- Specified by:
with
in interfaceMutableByteCollection
- Specified by:
with
in interfaceMutableByteSet
-
without
public ByteHashSet without(byte element)
- Specified by:
without
in interfaceMutableByteCollection
- Specified by:
without
in interfaceMutableByteSet
-
withAll
public ByteHashSet withAll(ByteIterable elements)
- Specified by:
withAll
in interfaceMutableByteCollection
- Specified by:
withAll
in interfaceMutableByteSet
-
withoutAll
public ByteHashSet withoutAll(ByteIterable elements)
- Specified by:
withoutAll
in interfaceMutableByteCollection
- Specified by:
withoutAll
in interfaceMutableByteSet
-
asUnmodifiable
public MutableByteSet asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableByteCollection
- Specified by:
asUnmodifiable
in interfaceMutableByteSet
-
asSynchronized
public MutableByteSet asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableByteCollection
- Specified by:
asSynchronized
in interfaceMutableByteSet
-
toImmutable
public ImmutableByteSet toImmutable()
Description copied from interface:MutableByteSet
Returns an immutable copy of this set.- Specified by:
toImmutable
in interfaceByteSet
- Specified by:
toImmutable
in interfaceMutableByteCollection
- Specified by:
toImmutable
in interfaceMutableByteSet
-
newEmpty
public ByteHashSet newEmpty()
Description copied from interface:MutableByteSet
Creates a new empty mutable version of the same Set type.- Specified by:
newEmpty
in interfaceMutableByteCollection
- Specified by:
newEmpty
in interfaceMutableByteSet
- 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
-
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
-
containsAll
public boolean containsAll(byte... source)
Description copied from interface:ByteIterable
Returns true if all of the values specified in the source array are contained in the ByteIterable, and false if they are not.- Specified by:
containsAll
in interfaceByteIterable
-
containsAll
public boolean containsAll(ByteIterable source)
Description copied from interface:ByteIterable
Returns true if all of the values specified in the source ByteIterable are contained in the ByteIterable, and false if they are not.- Specified by:
containsAll
in interfaceByteIterable
-
forEach
public void forEach(ByteProcedure procedure)
Description copied from interface:ByteIterable
Applies the ByteProcedure to each element in the ByteIterable.- Specified by:
forEach
in interfaceByteIterable
-
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 ByteHashSet 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 interfaceByteIterable
- Specified by:
select
in interfaceByteSet
- Specified by:
select
in interfaceMutableByteCollection
- Specified by:
select
in interfaceMutableByteSet
-
reject
public MutableByteSet 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 interfaceByteIterable
- Specified by:
reject
in interfaceByteSet
- Specified by:
reject
in interfaceMutableByteCollection
- Specified by:
reject
in interfaceMutableByteSet
-
collect
public <V> MutableSet<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 interfaceByteIterable
- Specified by:
collect
in interfaceByteSet
- Specified by:
collect
in interfaceMutableByteCollection
- Specified by:
collect
in interfaceMutableByteSet
-
detectIfNone
public byte detectIfNone(BytePredicate predicate, byte ifNone)
- Specified by:
detectIfNone
in interfaceByteIterable
-
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
-
toList
public MutableByteList toList()
Description copied from interface:ByteIterable
Converts the ByteIterable to a new MutableByteList.- Specified by:
toList
in interfaceByteIterable
-
toSet
public MutableByteSet toSet()
Description copied from interface:ByteIterable
Converts the ByteIterable to a new MutableByteSet.- Specified by:
toSet
in interfaceByteIterable
-
toBag
public MutableByteBag toBag()
Description copied from interface:ByteIterable
Converts the ByteIterable to a new MutableByteBag.- Specified by:
toBag
in interfaceByteIterable
-
asLazy
public LazyByteIterable asLazy()
Description copied from interface:ByteIterable
Returns a LazyByteIterable adapter wrapping the source ByteIterable.- Specified by:
asLazy
in interfaceByteIterable
-
sum
public long sum()
- Specified by:
sum
in interfaceByteIterable
-
max
public byte max()
- Specified by:
max
in interfaceByteIterable
-
maxIfEmpty
public byte maxIfEmpty(byte defaultValue)
- Specified by:
maxIfEmpty
in interfaceByteIterable
-
min
public byte min()
- Specified by:
min
in interfaceByteIterable
-
minIfEmpty
public byte minIfEmpty(byte defaultValue)
- Specified by:
minIfEmpty
in interfaceByteIterable
-
average
public double average()
- Specified by:
average
in interfaceByteIterable
-
median
public double median()
- Specified by:
median
in interfaceByteIterable
-
toSortedArray
public byte[] toSortedArray()
- Specified by:
toSortedArray
in interfaceByteIterable
-
toSortedList
public MutableByteList toSortedList()
- Specified by:
toSortedList
in interfaceByteIterable
-
freeze
public ByteSet freeze()
Description copied from interface:MutableByteSet
Returns a frozen copy of this set. A frozen copy is the same thing as an immutable copy without safe-publish guarantees.- Specified by:
freeze
in interfaceByteSet
- Specified by:
freeze
in interfaceMutableByteSet
-
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
-
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.
-
-