Class ShortHashSet
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractShortIterable
-
- org.eclipse.collections.impl.set.primitive.AbstractShortSet
-
- org.eclipse.collections.impl.set.mutable.primitive.ShortHashSet
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,MutableShortCollection
,PrimitiveIterable
,MutableShortSet
,ShortSet
,ShortIterable
public class ShortHashSet extends AbstractShortSet implements MutableShortSet, java.io.Externalizable
This file was automatically generated from template file primitiveHashSet.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ShortHashSet.ImmutableShortHashSet
private class
ShortHashSet.InternalShortIterator
-
Field Summary
Fields Modifier and Type Field Description private static int
CACHE_LINE_SIZE
private boolean
copyOnWrite
private static int
DEFAULT_INITIAL_CAPACITY
private static short
EMPTY
private static int
INITIAL_LINEAR_PROBE
private static int
KEY_SIZE
private int
occupiedWithData
private int
occupiedWithSentinels
private static short
REMOVED
private static long
serialVersionUID
private short[]
table
private int
zeroToThirtyOne
private int
zeroToThirtyOneOccupied
-
Constructor Summary
Constructors Constructor Description ShortHashSet()
ShortHashSet(int initialCapacity)
ShortHashSet(short... elements)
ShortHashSet(ShortIterable elements)
ShortHashSet(ShortHashSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(short element)
boolean
addAll(short... source)
boolean
addAll(ShortIterable source)
protected void
allocateTable(int sizeToAllocate)
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(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
.MutableShortSet
asSynchronized()
MutableShortSet
asUnmodifiable()
RichIterable<ShortIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableSet<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.<V,R extends java.util.Collection<V>>
Rcollect(ShortToObjectFunction<? extends V> function, R target)
Same asShortIterable.collect(ShortToObjectFunction)
, only the results are added to the target Collection.void
compact()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels.boolean
contains(short value)
Returns true if the value is contained in the ShortIterable, and false if it is not.private void
copyTable()
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.ShortSet
freeze()
Returns a frozen copy of this set.int
hashCode()
Follows the same general contract asSet.hashCode()
.<T> T
injectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)
private static boolean
isBetweenZeroAndThirtyOne(short value)
private static boolean
isNonSentinel(short value)
private int
mask(int spread)
short
max()
private int
maxOccupiedWithData()
short
min()
ShortHashSet
newEmpty()
Creates a new empty ShortHashSet.static ShortHashSet
newSet(ShortIterable source)
static ShortHashSet
newSetWith(short... source)
(package private) int
probe(short element)
(package private) int
probeThree(short element, int removedIndex)
(package private) int
probeTwo(short element, int removedIndex)
void
readExternal(java.io.ObjectInput in)
private void
rehash(int newCapacity)
private void
rehashAndGrow()
ShortHashSet
reject(ShortPredicate predicate)
Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.<R extends MutableShortCollection>
Rreject(ShortPredicate predicate, R target)
Same asShortIterable.reject(ShortPredicate)
, only the results are added to the target MutableShortCollection.boolean
remove(short value)
boolean
removeAll(short... source)
boolean
removeAll(ShortIterable source)
private boolean
removeZeroToThirtyOne(short value)
boolean
retainAll(short... source)
boolean
retainAll(ShortIterable source)
ShortHashSet
select(ShortPredicate predicate)
Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.<R extends MutableShortCollection>
Rselect(ShortPredicate predicate, R target)
Same asShortIterable.select(ShortPredicate)
, only the results are added to the target MutableShortCollection.MutableShortIterator
shortIterator()
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.private int
smallestPowerOfTwoGreaterThan(int n)
(package private) int
spreadAndMask(short element)
(package private) int
spreadTwoAndMask(short element)
long
sum()
short[]
toArray()
Converts the ShortIterable to a primitive short array.short[]
toArray(short[] array)
Converts the ShortIterable to a primitive short array.ImmutableShortSet
toImmutable()
Returns an immutable copy of this set.ShortHashSet
with(short element)
ShortHashSet
withAll(ShortIterable elements)
ShortHashSet
without(short element)
ShortHashSet
withoutAll(ShortIterable elements)
void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class org.eclipse.collections.impl.set.primitive.AbstractShortSet
cartesianProduct, equals
-
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.collection.primitive.MutableShortCollection
removeIf
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.MutableShortSet
difference, intersect, symmetricDifference, tap, union
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Methods inherited from interface org.eclipse.collections.api.ShortIterable
asLazy, average, averageIfEmpty, 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, noneSatisfy, reduce, reduceIfEmpty, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList, toSortedList, toSortedListBy, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.ShortSet
cartesianProduct, equals, isProperSubsetOf, isSubsetOf, tap
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_CAPACITY
private static final int DEFAULT_INITIAL_CAPACITY
- See Also:
- Constant Field Values
-
EMPTY
private static final short EMPTY
- See Also:
- Constant Field Values
-
REMOVED
private static final short REMOVED
- See Also:
- Constant Field Values
-
CACHE_LINE_SIZE
private static final int CACHE_LINE_SIZE
- See Also:
- Constant Field Values
-
KEY_SIZE
private static final int KEY_SIZE
- See Also:
- Constant Field Values
-
INITIAL_LINEAR_PROBE
private static final int INITIAL_LINEAR_PROBE
- See Also:
- Constant Field Values
-
table
private short[] table
-
occupiedWithData
private int occupiedWithData
-
occupiedWithSentinels
private int occupiedWithSentinels
-
zeroToThirtyOne
private int zeroToThirtyOne
-
zeroToThirtyOneOccupied
private int zeroToThirtyOneOccupied
-
copyOnWrite
private transient boolean copyOnWrite
-
-
Constructor Detail
-
ShortHashSet
public ShortHashSet()
-
ShortHashSet
public ShortHashSet(int initialCapacity)
-
ShortHashSet
public ShortHashSet(short... elements)
-
ShortHashSet
public ShortHashSet(ShortIterable elements)
-
ShortHashSet
public ShortHashSet(ShortHashSet set)
-
-
Method Detail
-
smallestPowerOfTwoGreaterThan
private int smallestPowerOfTwoGreaterThan(int n)
-
newSet
public static ShortHashSet newSet(ShortIterable source)
-
newSetWith
public static ShortHashSet newSetWith(short... source)
-
isBetweenZeroAndThirtyOne
private static boolean isBetweenZeroAndThirtyOne(short value)
-
hashCode
public int hashCode()
Description copied from interface:ShortSet
Follows the same general contract asSet.hashCode()
.- Specified by:
hashCode
in interfaceShortSet
- Specified by:
hashCode
in classAbstractShortSet
-
size
public int size()
Description copied from interface:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
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
-
add
public boolean add(short element)
- Specified by:
add
in interfaceMutableShortCollection
-
addAll
public boolean addAll(short... source)
- Specified by:
addAll
in interfaceMutableShortCollection
-
addAll
public boolean addAll(ShortIterable source)
- Specified by:
addAll
in interfaceMutableShortCollection
-
remove
public boolean remove(short value)
- Specified by:
remove
in interfaceMutableShortCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(short value)
-
removeAll
public boolean removeAll(ShortIterable source)
- Specified by:
removeAll
in interfaceMutableShortCollection
-
removeAll
public boolean removeAll(short... source)
- Specified by:
removeAll
in interfaceMutableShortCollection
-
retainAll
public boolean retainAll(ShortIterable source)
- Specified by:
retainAll
in interfaceMutableShortCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(short... source)
- Specified by:
retainAll
in interfaceMutableShortCollection
- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableShortCollection
-
with
public ShortHashSet with(short element)
- Specified by:
with
in interfaceMutableShortCollection
- Specified by:
with
in interfaceMutableShortSet
-
without
public ShortHashSet without(short element)
- Specified by:
without
in interfaceMutableShortCollection
- Specified by:
without
in interfaceMutableShortSet
-
withAll
public ShortHashSet withAll(ShortIterable elements)
- Specified by:
withAll
in interfaceMutableShortCollection
- Specified by:
withAll
in interfaceMutableShortSet
-
withoutAll
public ShortHashSet withoutAll(ShortIterable elements)
- Specified by:
withoutAll
in interfaceMutableShortCollection
- Specified by:
withoutAll
in interfaceMutableShortSet
-
asUnmodifiable
public MutableShortSet asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableShortCollection
- Specified by:
asUnmodifiable
in interfaceMutableShortSet
-
asSynchronized
public MutableShortSet asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableShortCollection
- Specified by:
asSynchronized
in interfaceMutableShortSet
-
toImmutable
public ImmutableShortSet toImmutable()
Description copied from interface:MutableShortSet
Returns an immutable copy of this set.- Specified by:
toImmutable
in interfaceMutableShortCollection
- Specified by:
toImmutable
in interfaceMutableShortSet
- Specified by:
toImmutable
in interfaceShortSet
-
shortIterator
public MutableShortIterator 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
-
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
-
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
-
each
public void each(ShortProcedure procedure)
Description copied from interface:ShortIterable
A synonym for forEach.- Specified by:
each
in interfaceShortIterable
- Since:
- 7.0.
-
select
public ShortHashSet select(ShortPredicate predicate)
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 interfaceMutableShortCollection
- Specified by:
select
in interfaceMutableShortSet
- Specified by:
select
in interfaceShortIterable
- Specified by:
select
in interfaceShortSet
-
select
public <R extends MutableShortCollection> R select(ShortPredicate predicate, R target)
Description copied from interface:ShortIterable
Same asShortIterable.select(ShortPredicate)
, only the results are added to the target MutableShortCollection.- Specified by:
select
in interfaceShortIterable
- Since:
- 8.1.
-
reject
public ShortHashSet reject(ShortPredicate predicate)
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 interfaceMutableShortCollection
- Specified by:
reject
in interfaceMutableShortSet
- Specified by:
reject
in interfaceShortIterable
- Specified by:
reject
in interfaceShortSet
-
reject
public <R extends MutableShortCollection> R reject(ShortPredicate predicate, R target)
Description copied from interface:ShortIterable
Same asShortIterable.reject(ShortPredicate)
, only the results are added to the target MutableShortCollection.- Specified by:
reject
in interfaceShortIterable
- Since:
- 8.1.
-
collect
public <V> MutableSet<V> collect(ShortToObjectFunction<? extends V> function)
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 interfaceMutableShortCollection
- Specified by:
collect
in interfaceMutableShortSet
- Specified by:
collect
in interfaceShortIterable
- Specified by:
collect
in interfaceShortSet
-
collect
public <V,R extends java.util.Collection<V>> R collect(ShortToObjectFunction<? extends V> function, R target)
Description copied from interface:ShortIterable
Same asShortIterable.collect(ShortToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceShortIterable
- Since:
- 8.1.
-
detectIfNone
public short detectIfNone(ShortPredicate predicate, short ifNone)
- Specified by:
detectIfNone
in interfaceShortIterable
-
count
public int count(ShortPredicate predicate)
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
public boolean anySatisfy(ShortPredicate predicate)
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
public boolean allSatisfy(ShortPredicate predicate)
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
-
sum
public long sum()
- Specified by:
sum
in interfaceShortIterable
-
max
public short max()
- Specified by:
max
in interfaceShortIterable
-
min
public short min()
- Specified by:
min
in interfaceShortIterable
-
freeze
public ShortSet freeze()
Description copied from interface:MutableShortSet
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 interfaceMutableShortSet
- Specified by:
freeze
in interfaceShortSet
-
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, ObjectShortToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceShortIterable
-
chunk
public RichIterable<ShortIterable> chunk(int size)
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.
-
newEmpty
public ShortHashSet newEmpty()
Creates a new empty ShortHashSet.- Specified by:
newEmpty
in interfaceMutableShortCollection
- Specified by:
newEmpty
in interfaceMutableShortSet
- Since:
- 9.2.
-
compact
public void compact()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels.
-
rehashAndGrow
private void rehashAndGrow()
-
rehash
private void rehash(int newCapacity)
-
allocateTable
protected void allocateTable(int sizeToAllocate)
-
probe
int probe(short element)
-
probeTwo
int probeTwo(short element, int removedIndex)
-
probeThree
int probeThree(short element, int removedIndex)
-
spreadAndMask
int spreadAndMask(short element)
-
spreadTwoAndMask
int spreadTwoAndMask(short element)
-
mask
private int mask(int spread)
-
copyTable
private void copyTable()
-
maxOccupiedWithData
private int maxOccupiedWithData()
-
isNonSentinel
private static boolean isNonSentinel(short value)
-
-