Class LongHashSet
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractLongIterable
org.eclipse.collections.impl.set.primitive.AbstractLongSet
org.eclipse.collections.impl.set.mutable.primitive.LongHashSet
- All Implemented Interfaces:
Externalizable, Serializable, MutableLongCollection, LongIterable, PrimitiveIterable, LongSet, MutableLongSet
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 longprivate static final intprivate static final intprivate intprivate intprivate static final longprivate static final longprivate long[]private intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionLongHashSet(int initialCapacity) LongHashSet(long... elements) LongHashSet(LongIterable elements) LongHashSet(LongHashSet set) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(long element) booleanaddAll(long... source) booleanaddAll(LongIterable source) protected voidallocateTable(int sizeToAllocate) booleanallSatisfy(LongPredicate predicate) Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(LongPredicate predicate) Returns true if any of the elements in the LongIterable 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(LongToObjectFunction<? 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(LongToObjectFunction<? extends V> function, R target) Same asLongIterable.collect(LongToObjectFunction), only the results are added to the target Collection.voidcompact()Deprecated.booleancontains(long value) Returns true if the value is contained in the LongIterable, and false if it is not.private voidintcount(LongPredicate predicate) Returns a count of the number of elements in the LongIterable that return true for the specified predicate.longdetectIfNone(LongPredicate predicate, long ifNone) voideach(LongProcedure 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, ObjectLongToObjectFunction<? super T, ? extends T> function) private static booleanisBetweenZeroAndThirtyOne(long value) private static booleanisNonSentinel(long value) Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.private intmask(int spread) longmax()private intlongmin()newEmpty()Creates a new empty LongHashSet.static LongHashSetnewSet(LongIterable source) static LongHashSetnewSetWith(long... source) (package private) intprobe(long element) (package private) intprobeThree(long element, int removedIndex) (package private) intprobeTwo(long element, int removedIndex) voidprivate voidrehash(int newCapacity) private voidreject(LongPredicate predicate) Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.<R extends MutableLongCollection>
Rreject(LongPredicate predicate, R target) Same asLongIterable.reject(LongPredicate), only the results are added to the target MutableLongCollection.booleanremove(long value) booleanremoveAll(long... source) booleanremoveAll(LongIterable source) private booleanremoveZeroToThirtyOne(long value) booleanretainAll(long... source) booleanretainAll(LongIterable source) select(LongPredicate predicate) Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.<R extends MutableLongCollection>
Rselect(LongPredicate predicate, R target) Same asLongIterable.select(LongPredicate), only the results are added to the target MutableLongCollection.intsize()Returns the number of items in this iterable.private int(package private) intspreadAndMask(long element) (package private) intspreadTwoAndMask(long element) longsum()long[]toArray()Converts the LongIterable to a primitive long array.long[]toArray(long[] array) Converts the LongIterable to a primitive long array.Returns an immutable copy of this set.booleanwith(long element) withAll(LongIterable elements) without(long element) withoutAll(LongIterable elements) voidMethods inherited from class AbstractLongSet
cartesianProduct, equalsMethods inherited from class AbstractLongIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface LongIterable
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 LongSet
cartesianProduct, equals, isProperSubsetOf, isSubsetOf, tapMethods inherited from interface MutableLongCollection
removeIfMethods inherited from interface MutableLongSet
difference, intersect, symmetricDifference, tap, unionMethods inherited from interface PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
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 long EMPTY- See Also:
-
REMOVED
private static final long 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 long[] table -
occupiedWithData
private int occupiedWithData -
occupiedWithSentinels
private int occupiedWithSentinels -
zeroToThirtyOne
private int zeroToThirtyOne -
zeroToThirtyOneOccupied
private int zeroToThirtyOneOccupied -
copyOnWrite
private transient boolean copyOnWrite
-
-
Constructor Details
-
LongHashSet
public LongHashSet() -
LongHashSet
public LongHashSet(int initialCapacity) -
LongHashSet
public LongHashSet(long... elements) -
LongHashSet
-
LongHashSet
-
-
Method Details
-
boxed
- Specified by:
boxedin interfaceMutableLongSet
-
smallestPowerOfTwoGreaterThan
private int smallestPowerOfTwoGreaterThan(int n) -
newSet
-
newSetWith
-
isBetweenZeroAndThirtyOne
private static boolean isBetweenZeroAndThirtyOne(long value) -
hashCode
public int hashCode()Description copied from interface:LongSetFollows the same general contract asSet.hashCode().- Specified by:
hashCodein interfaceLongSet- Specified by:
hashCodein classAbstractLongSet
-
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(long element) - Specified by:
addin interfaceMutableLongCollection
-
addAll
public boolean addAll(long... source) - Specified by:
addAllin interfaceMutableLongCollection
-
addAll
- Specified by:
addAllin interfaceMutableLongCollection
-
remove
public boolean remove(long value) - Specified by:
removein interfaceMutableLongCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(long value) -
removeAll
- Specified by:
removeAllin interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source) - Specified by:
removeAllin interfaceMutableLongCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableLongCollection- See Also:
-
retainAll
public boolean retainAll(long... source) - Specified by:
retainAllin interfaceMutableLongCollection- See Also:
-
clear
public void clear()- Specified by:
clearin interfaceMutableLongCollection
-
with
- Specified by:
within interfaceMutableLongCollection- Specified by:
within interfaceMutableLongSet
-
without
- Specified by:
withoutin interfaceMutableLongCollection- Specified by:
withoutin interfaceMutableLongSet
-
withAll
- Specified by:
withAllin interfaceMutableLongCollection- Specified by:
withAllin interfaceMutableLongSet
-
withoutAll
- Specified by:
withoutAllin interfaceMutableLongCollection- Specified by:
withoutAllin interfaceMutableLongSet
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableLongCollection- Specified by:
asUnmodifiablein interfaceMutableLongSet
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableLongCollection- Specified by:
asSynchronizedin interfaceMutableLongSet
-
toImmutable
Description copied from interface:LongSetReturns an immutable copy of this set. If the set is immutable, it returns itself.- Specified by:
toImmutablein interfaceLongSet- Specified by:
toImmutablein interfaceMutableLongCollection- Specified by:
toImmutablein interfaceMutableLongSet
-
longIterator
Description copied from interface:LongIterableReturns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.- Specified by:
longIteratorin interfaceLongIterable- Specified by:
longIteratorin interfaceMutableLongCollection
-
toArray
public long[] toArray()Description copied from interface:LongIterableConverts the LongIterable to a primitive long array.- Specified by:
toArrayin interfaceLongIterable
-
toArray
public long[] toArray(long[] array) Description copied from interface:LongIterableConverts the LongIterable to a primitive long 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 interfaceLongIterable
-
contains
public boolean contains(long value) Description copied from interface:LongIterableReturns true if the value is contained in the LongIterable, and false if it is not.- Specified by:
containsin interfaceLongIterable
-
each
Description copied from interface:LongIterableA synonym for forEach.- Specified by:
eachin interfaceLongIterable- Since:
- 7.0.
-
select
Description copied from interface:LongIterableReturns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.- Specified by:
selectin interfaceLongIterable- Specified by:
selectin interfaceLongSet- Specified by:
selectin interfaceMutableLongCollection- Specified by:
selectin interfaceMutableLongSet
-
select
Description copied from interface:LongIterableSame asLongIterable.select(LongPredicate), only the results are added to the target MutableLongCollection.- Specified by:
selectin interfaceLongIterable- Since:
- 8.1.
-
reject
Description copied from interface:LongIterableReturns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.- Specified by:
rejectin interfaceLongIterable- Specified by:
rejectin interfaceLongSet- Specified by:
rejectin interfaceMutableLongCollection- Specified by:
rejectin interfaceMutableLongSet
-
reject
Description copied from interface:LongIterableSame asLongIterable.reject(LongPredicate), only the results are added to the target MutableLongCollection.- Specified by:
rejectin interfaceLongIterable- Since:
- 8.1.
-
collect
Description copied from interface:LongIterableReturns 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 interfaceLongIterable- Specified by:
collectin interfaceLongSet- Specified by:
collectin interfaceMutableLongCollection- Specified by:
collectin interfaceMutableLongSet
-
collect
Description copied from interface:LongIterableSame asLongIterable.collect(LongToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceLongIterable- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNonein interfaceLongIterable
-
count
Description copied from interface:LongIterableReturns a count of the number of elements in the LongIterable that return true for the specified predicate.- Specified by:
countin interfaceLongIterable
-
anySatisfy
Description copied from interface:LongIterableReturns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceLongIterable
-
allSatisfy
Description copied from interface:LongIterableReturns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceLongIterable
-
sum
public long sum()- Specified by:
sumin interfaceLongIterable
-
max
public long max()- Specified by:
maxin interfaceLongIterable
-
min
public long min()- Specified by:
minin interfaceLongIterable
-
freeze
Description copied from interface:LongSetReturns 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 interfaceLongSet- Specified by:
freezein interfaceMutableLongSet
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
injectInto
public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoin interfaceLongIterable
-
chunk
Description copied from interface:LongIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceLongIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingLongIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
newEmpty
Creates a new empty LongHashSet.- Specified by:
newEmptyin interfaceMutableLongCollection- Specified by:
newEmptyin interfaceMutableLongSet- 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(long element) -
probeTwo
int probeTwo(long element, int removedIndex) -
probeThree
int probeThree(long element, int removedIndex) -
spreadAndMask
int spreadAndMask(long element) -
spreadTwoAndMask
int spreadTwoAndMask(long element) -
mask
private int mask(int spread) -
copyTable
private void copyTable() -
maxOccupiedWithData
private int maxOccupiedWithData() -
isNonSentinel
private static boolean isNonSentinel(long value)
-
trimToSize()instead