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:
Externalizable, Serializable, MutableShortCollection, PrimitiveIterable, MutableShortSet, ShortSet, ShortIterable
This file was automatically generated from template file primitiveHashSet.stg.
- Since:
- 3.0.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate booleanprivate static final intprivate static final shortprivate static final intprivate static final intprivate intprivate intprivate static final shortprivate static final longprivate short[]private intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionShortHashSet(int initialCapacity) ShortHashSet(short... elements) ShortHashSet(ShortIterable elements) ShortHashSet(ShortHashSet set) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(short element) booleanaddAll(short... source) booleanaddAll(ShortIterable source) protected voidallocateTable(int sizeToAllocate) 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(Appendable appendable, String start, String separator, String end) Prints a string representation of this collection onto the givenAppendable.boxed()chunk(int size) Partitions elements in fixed size chunks.voidclear()<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 Collection<V>>
Rcollect(ShortToObjectFunction<? extends V> function, R target) Same asShortIterable.collect(ShortToObjectFunction), only the results are added to the target Collection.voidcompact()Deprecated.booleancontains(short value) Returns true if the value is contained in the ShortIterable, and false if it is not.private voidintcount(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.freeze()Returns a frozen copy of this set.inthashCode()Follows the same general contract asSet.hashCode().<T> TinjectInto(T injectedValue, ObjectShortToObjectFunction<? super T, ? extends T> function) private static booleanisBetweenZeroAndThirtyOne(short value) private static booleanisNonSentinel(short value) private intmask(int spread) shortmax()private intshortmin()newEmpty()Creates a new empty ShortHashSet.static ShortHashSetnewSet(ShortIterable source) static ShortHashSetnewSetWith(short... source) (package private) intprobe(short element) (package private) intprobeThree(short element, int removedIndex) (package private) intprobeTwo(short element, int removedIndex) voidprivate voidrehash(int newCapacity) private voidreject(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.booleanremove(short value) booleanremoveAll(short... source) booleanremoveAll(ShortIterable source) private booleanremoveZeroToThirtyOne(short value) booleanretainAll(short... source) booleanretainAll(ShortIterable source) 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.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.private int(package private) intspreadAndMask(short element) (package private) intspreadTwoAndMask(short element) longsum()short[]toArray()Converts the ShortIterable to a primitive short array.short[]toArray(short[] array) Converts the ShortIterable to a primitive short array.Returns an immutable copy of this set.booleanwith(short element) withAll(ShortIterable elements) without(short element) withoutAll(ShortIterable elements) voidMethods inherited from class AbstractShortSet
cartesianProduct, equalsMethods inherited from class AbstractShortIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface MutableShortCollection
removeIfMethods inherited from interface MutableShortSet
difference, intersect, symmetricDifference, tap, unionMethods inherited from interface PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toStringMethods inherited from interface 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, toSortedListByMethods inherited from interface ShortSet
cartesianProduct, equals, isProperSubsetOf, isSubsetOf, tap
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT_INITIAL_CAPACITY
private static final int DEFAULT_INITIAL_CAPACITY- See Also:
-
EMPTY
private static final short EMPTY- See Also:
-
REMOVED
private static final short REMOVED- See Also:
-
CACHE_LINE_SIZE
private static final int CACHE_LINE_SIZE- See Also:
-
KEY_SIZE
private static final int KEY_SIZE- See Also:
-
INITIAL_LINEAR_PROBE
private static final int INITIAL_LINEAR_PROBE- See Also:
-
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 Details
-
ShortHashSet
public ShortHashSet() -
ShortHashSet
public ShortHashSet(int initialCapacity) -
ShortHashSet
public ShortHashSet(short... elements) -
ShortHashSet
-
ShortHashSet
-
-
Method Details
-
boxed
- Specified by:
boxedin interfaceMutableShortSet
-
smallestPowerOfTwoGreaterThan
private int smallestPowerOfTwoGreaterThan(int n) -
newSet
-
newSetWith
-
isBetweenZeroAndThirtyOne
private static boolean isBetweenZeroAndThirtyOne(short value) -
hashCode
public int hashCode()Description copied from interface:ShortSetFollows the same general contract asSet.hashCode().- Specified by:
hashCodein interfaceShortSet- Specified by:
hashCodein classAbstractShortSet
-
size
public int size()Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein interfacePrimitiveIterable
-
appendString
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
-
add
public boolean add(short element) - Specified by:
addin interfaceMutableShortCollection
-
addAll
public boolean addAll(short... source) - Specified by:
addAllin interfaceMutableShortCollection
-
addAll
- Specified by:
addAllin interfaceMutableShortCollection
-
remove
public boolean remove(short value) - Specified by:
removein interfaceMutableShortCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(short value) -
removeAll
- Specified by:
removeAllin interfaceMutableShortCollection
-
removeAll
public boolean removeAll(short... source) - Specified by:
removeAllin interfaceMutableShortCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableShortCollection- See Also:
-
retainAll
public boolean retainAll(short... source) - Specified by:
retainAllin interfaceMutableShortCollection- See Also:
-
clear
public void clear()- Specified by:
clearin interfaceMutableShortCollection
-
with
- Specified by:
within interfaceMutableShortCollection- Specified by:
within interfaceMutableShortSet
-
without
- Specified by:
withoutin interfaceMutableShortCollection- Specified by:
withoutin interfaceMutableShortSet
-
withAll
- Specified by:
withAllin interfaceMutableShortCollection- Specified by:
withAllin interfaceMutableShortSet
-
withoutAll
- Specified by:
withoutAllin interfaceMutableShortCollection- Specified by:
withoutAllin interfaceMutableShortSet
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableShortCollection- Specified by:
asUnmodifiablein interfaceMutableShortSet
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableShortCollection- Specified by:
asSynchronizedin interfaceMutableShortSet
-
toImmutable
Description copied from interface:ShortSetReturns an immutable copy of this set. If the set is immutable, it returns itself.- Specified by:
toImmutablein interfaceMutableShortCollection- Specified by:
toImmutablein interfaceMutableShortSet- Specified by:
toImmutablein interfaceShortSet
-
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
-
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
-
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
-
each
Description copied from interface:ShortIterableA synonym for forEach.- Specified by:
eachin interfaceShortIterable- Since:
- 7.0.
-
select
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 interfaceMutableShortCollection- Specified by:
selectin interfaceMutableShortSet- Specified by:
selectin interfaceShortIterable- Specified by:
selectin interfaceShortSet
-
select
Description copied from interface:ShortIterableSame asShortIterable.select(ShortPredicate), only the results are added to the target MutableShortCollection.- Specified by:
selectin interfaceShortIterable- Since:
- 8.1.
-
reject
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 interfaceMutableShortCollection- Specified by:
rejectin interfaceMutableShortSet- Specified by:
rejectin interfaceShortIterable- Specified by:
rejectin interfaceShortSet
-
reject
Description copied from interface:ShortIterableSame asShortIterable.reject(ShortPredicate), only the results are added to the target MutableShortCollection.- Specified by:
rejectin interfaceShortIterable- Since:
- 8.1.
-
collect
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 interfaceMutableShortCollection- Specified by:
collectin interfaceMutableShortSet- Specified by:
collectin interfaceShortIterable- Specified by:
collectin interfaceShortSet
-
collect
public <V, R extends Collection<V>> R collect(ShortToObjectFunction<? extends V> function, R target) Description copied from interface:ShortIterableSame asShortIterable.collect(ShortToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceShortIterable- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNonein interfaceShortIterable
-
count
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
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
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
-
sum
public long sum()- Specified by:
sumin interfaceShortIterable
-
max
public short max()- Specified by:
maxin interfaceShortIterable
-
min
public short min()- Specified by:
minin interfaceShortIterable
-
freeze
Description copied from interface:ShortSetReturns a frozen copy of this set. If the set is frozen, it returns itself. A frozen copy is the same thing as an immutable copy without safe-publish guarantees.- Specified by:
freezein interfaceMutableShortSet- Specified by:
freezein interfaceShortSet
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
injectInto
public <T> T injectInto(T injectedValue, ObjectShortToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoin interfaceShortIterable
-
chunk
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.
-
newEmpty
Creates a new empty ShortHashSet.- Specified by:
newEmptyin interfaceMutableShortCollection- Specified by:
newEmptyin interfaceMutableShortSet- Since:
- 9.2.
-
trimToSize
public boolean trimToSize()- Since:
- 12.0
-
compact
Deprecated.since 12.0 - UsetrimToSize()insteadRehashes 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)
-
trimToSize()instead