Class CharHashSet
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractCharIterable
-
- org.eclipse.collections.impl.set.primitive.AbstractCharSet
-
- org.eclipse.collections.impl.set.mutable.primitive.CharHashSet
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,CharIterable,MutableCharCollection,PrimitiveIterable,CharSet,MutableCharSet
public class CharHashSet extends AbstractCharSet implements MutableCharSet, 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 classCharHashSet.ImmutableCharHashSetprivate classCharHashSet.InternalCharIterator
-
Field Summary
Fields Modifier and Type Field Description private static intCACHE_LINE_SIZEprivate booleancopyOnWriteprivate static intDEFAULT_INITIAL_CAPACITYprivate static charEMPTYprivate static intINITIAL_LINEAR_PROBEprivate static intKEY_SIZEprivate intoccupiedWithDataprivate intoccupiedWithSentinelsprivate static charREMOVEDprivate static longserialVersionUIDprivate char[]tableprivate intzeroToThirtyOneprivate intzeroToThirtyOneOccupied
-
Constructor Summary
Constructors Constructor Description CharHashSet()CharHashSet(char... elements)CharHashSet(int initialCapacity)CharHashSet(CharIterable elements)CharHashSet(CharHashSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(char element)booleanaddAll(char... source)booleanaddAll(CharIterable source)protected voidallocateTable(int sizeToAllocate)booleanallSatisfy(CharPredicate predicate)Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(CharPredicate predicate)Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.voidappendString(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.MutableCharSetasSynchronized()MutableCharSetasUnmodifiable()MutableSet<java.lang.Character>boxed()MutableCharIteratorcharIterator()Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.RichIterable<CharIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<V> MutableSet<V>collect(CharToObjectFunction<? 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(CharToObjectFunction<? extends V> function, R target)Same asCharIterable.collect(CharToObjectFunction), only the results are added to the target Collection.voidcompact()Deprecated.since 12.0 - UsetrimToSize()insteadbooleancontains(char value)Returns true if the value is contained in the CharIterable, and false if it is not.private voidcopyTable()intcount(CharPredicate predicate)Returns a count of the number of elements in the CharIterable that return true for the specified predicate.chardetectIfNone(CharPredicate predicate, char ifNone)voideach(CharProcedure procedure)A synonym for forEach.CharSetfreeze()Returns a frozen copy of this set.inthashCode()Follows the same general contract asSet.hashCode().<T> TinjectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)private static booleanisBetweenZeroAndThirtyOne(char value)private static booleanisNonSentinel(char value)private intmask(int spread)charmax()private intmaxOccupiedWithData()charmin()CharHashSetnewEmpty()Creates a new empty CharHashSet.static CharHashSetnewSet(CharIterable source)static CharHashSetnewSetWith(char... source)(package private) intprobe(char element)(package private) intprobeThree(char element, int removedIndex)(package private) intprobeTwo(char element, int removedIndex)voidreadExternal(java.io.ObjectInput in)private voidrehash(int newCapacity)private voidrehashAndGrow()CharHashSetreject(CharPredicate predicate)Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.<R extends MutableCharCollection>
Rreject(CharPredicate predicate, R target)Same asCharIterable.reject(CharPredicate), only the results are added to the target MutableCharCollection.booleanremove(char value)booleanremoveAll(char... source)booleanremoveAll(CharIterable source)private booleanremoveZeroToThirtyOne(char value)booleanretainAll(char... source)booleanretainAll(CharIterable source)CharHashSetselect(CharPredicate predicate)Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.<R extends MutableCharCollection>
Rselect(CharPredicate predicate, R target)Same asCharIterable.select(CharPredicate), only the results are added to the target MutableCharCollection.intsize()Returns the number of items in this iterable.private intsmallestPowerOfTwoGreaterThan(int n)(package private) intspreadAndMask(char element)(package private) intspreadTwoAndMask(char element)longsum()char[]toArray()Converts the CharIterable to a primitive char array.char[]toArray(char[] array)Converts the CharIterable to a primitive char array.ImmutableCharSettoImmutable()Returns an immutable copy of this set.booleantrimToSize()CharHashSetwith(char element)CharHashSetwithAll(CharIterable elements)CharHashSetwithout(char element)CharHashSetwithoutAll(CharIterable elements)voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class org.eclipse.collections.impl.set.primitive.AbstractCharSet
cartesianProduct, equals
-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractCharIterable
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.CharIterable
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.CharSet
cartesianProduct, equals, isProperSubsetOf, isSubsetOf, tap
-
Methods inherited from interface org.eclipse.collections.api.collection.primitive.MutableCharCollection
removeIf
-
Methods inherited from interface org.eclipse.collections.api.set.primitive.MutableCharSet
difference, intersect, symmetricDifference, tap, union
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
-
-
-
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 char EMPTY
- See Also:
- Constant Field Values
-
REMOVED
private static final char 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 char[] table
-
occupiedWithData
private int occupiedWithData
-
occupiedWithSentinels
private int occupiedWithSentinels
-
zeroToThirtyOne
private int zeroToThirtyOne
-
zeroToThirtyOneOccupied
private int zeroToThirtyOneOccupied
-
copyOnWrite
private transient boolean copyOnWrite
-
-
Constructor Detail
-
CharHashSet
public CharHashSet()
-
CharHashSet
public CharHashSet(int initialCapacity)
-
CharHashSet
public CharHashSet(char... elements)
-
CharHashSet
public CharHashSet(CharIterable elements)
-
CharHashSet
public CharHashSet(CharHashSet set)
-
-
Method Detail
-
boxed
public MutableSet<java.lang.Character> boxed()
- Specified by:
boxedin interfaceMutableCharSet
-
smallestPowerOfTwoGreaterThan
private int smallestPowerOfTwoGreaterThan(int n)
-
newSet
public static CharHashSet newSet(CharIterable source)
-
newSetWith
public static CharHashSet newSetWith(char... source)
-
isBetweenZeroAndThirtyOne
private static boolean isBetweenZeroAndThirtyOne(char value)
-
hashCode
public int hashCode()
Description copied from interface:CharSetFollows the same general contract asSet.hashCode().- Specified by:
hashCodein interfaceCharSet- Specified by:
hashCodein classAbstractCharSet
-
size
public int size()
Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein 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: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(char element)
- Specified by:
addin interfaceMutableCharCollection
-
addAll
public boolean addAll(char... source)
- Specified by:
addAllin interfaceMutableCharCollection
-
addAll
public boolean addAll(CharIterable source)
- Specified by:
addAllin interfaceMutableCharCollection
-
remove
public boolean remove(char value)
- Specified by:
removein interfaceMutableCharCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(char value)
-
removeAll
public boolean removeAll(CharIterable source)
- Specified by:
removeAllin interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source)
- Specified by:
removeAllin interfaceMutableCharCollection
-
retainAll
public boolean retainAll(CharIterable source)
- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(char... source)
- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clearin interfaceMutableCharCollection
-
with
public CharHashSet with(char element)
- Specified by:
within interfaceMutableCharCollection- Specified by:
within interfaceMutableCharSet
-
without
public CharHashSet without(char element)
- Specified by:
withoutin interfaceMutableCharCollection- Specified by:
withoutin interfaceMutableCharSet
-
withAll
public CharHashSet withAll(CharIterable elements)
- Specified by:
withAllin interfaceMutableCharCollection- Specified by:
withAllin interfaceMutableCharSet
-
withoutAll
public CharHashSet withoutAll(CharIterable elements)
- Specified by:
withoutAllin interfaceMutableCharCollection- Specified by:
withoutAllin interfaceMutableCharSet
-
asUnmodifiable
public MutableCharSet asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableCharCollection- Specified by:
asUnmodifiablein interfaceMutableCharSet
-
asSynchronized
public MutableCharSet asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableCharCollection- Specified by:
asSynchronizedin interfaceMutableCharSet
-
toImmutable
public ImmutableCharSet toImmutable()
Description copied from interface:MutableCharSetReturns an immutable copy of this set.- Specified by:
toImmutablein interfaceCharSet- Specified by:
toImmutablein interfaceMutableCharCollection- Specified by:
toImmutablein interfaceMutableCharSet
-
charIterator
public MutableCharIterator charIterator()
Description copied from interface:CharIterableReturns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIteratorin interfaceCharIterable- Specified by:
charIteratorin interfaceMutableCharCollection
-
toArray
public char[] toArray()
Description copied from interface:CharIterableConverts the CharIterable to a primitive char array.- Specified by:
toArrayin interfaceCharIterable
-
toArray
public char[] toArray(char[] array)
Description copied from interface:CharIterableConverts the CharIterable to a primitive char 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 interfaceCharIterable
-
contains
public boolean contains(char value)
Description copied from interface:CharIterableReturns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
containsin interfaceCharIterable
-
each
public void each(CharProcedure procedure)
Description copied from interface:CharIterableA synonym for forEach.- Specified by:
eachin interfaceCharIterable- Since:
- 7.0.
-
select
public CharHashSet select(CharPredicate predicate)
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
selectin interfaceCharIterable- Specified by:
selectin interfaceCharSet- Specified by:
selectin interfaceMutableCharCollection- Specified by:
selectin interfaceMutableCharSet
-
select
public <R extends MutableCharCollection> R select(CharPredicate predicate, R target)
Description copied from interface:CharIterableSame asCharIterable.select(CharPredicate), only the results are added to the target MutableCharCollection.- Specified by:
selectin interfaceCharIterable- Since:
- 8.1.
-
reject
public CharHashSet reject(CharPredicate predicate)
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
rejectin interfaceCharIterable- Specified by:
rejectin interfaceCharSet- Specified by:
rejectin interfaceMutableCharCollection- Specified by:
rejectin interfaceMutableCharSet
-
reject
public <R extends MutableCharCollection> R reject(CharPredicate predicate, R target)
Description copied from interface:CharIterableSame asCharIterable.reject(CharPredicate), only the results are added to the target MutableCharCollection.- Specified by:
rejectin interfaceCharIterable- Since:
- 8.1.
-
collect
public <V> MutableSet<V> collect(CharToObjectFunction<? extends V> function)
Description copied from interface:CharIterableReturns 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 interfaceCharIterable- Specified by:
collectin interfaceCharSet- Specified by:
collectin interfaceMutableCharCollection- Specified by:
collectin interfaceMutableCharSet
-
collect
public <V,R extends java.util.Collection<V>> R collect(CharToObjectFunction<? extends V> function, R target)
Description copied from interface:CharIterableSame asCharIterable.collect(CharToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceCharIterable- Since:
- 8.1.
-
detectIfNone
public char detectIfNone(CharPredicate predicate, char ifNone)
- Specified by:
detectIfNonein interfaceCharIterable
-
count
public int count(CharPredicate predicate)
Description copied from interface:CharIterableReturns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
countin interfaceCharIterable
-
anySatisfy
public boolean anySatisfy(CharPredicate predicate)
Description copied from interface:CharIterableReturns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceCharIterable
-
allSatisfy
public boolean allSatisfy(CharPredicate predicate)
Description copied from interface:CharIterableReturns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceCharIterable
-
sum
public long sum()
- Specified by:
sumin interfaceCharIterable
-
max
public char max()
- Specified by:
maxin interfaceCharIterable
-
min
public char min()
- Specified by:
minin interfaceCharIterable
-
freeze
public CharSet freeze()
Description copied from interface:MutableCharSetReturns a frozen copy of this set. A frozen copy is the same thing as an immutable copy without safe-publish guarantees.- Specified by:
freezein interfaceCharSet- Specified by:
freezein interfaceMutableCharSet
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
injectInto
public <T> T injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceCharIterable
-
chunk
public RichIterable<CharIterable> chunk(int size)
Description copied from interface:CharIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceCharIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingCharIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
newEmpty
public CharHashSet newEmpty()
Creates a new empty CharHashSet.- Specified by:
newEmptyin interfaceMutableCharCollection- Specified by:
newEmptyin interfaceMutableCharSet- Since:
- 9.2.
-
trimToSize
public boolean trimToSize()
- Since:
- 12.0
-
compact
@Deprecated public void 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(char element)
-
probeTwo
int probeTwo(char element, int removedIndex)
-
probeThree
int probeThree(char element, int removedIndex)
-
spreadAndMask
int spreadAndMask(char element)
-
spreadTwoAndMask
int spreadTwoAndMask(char element)
-
mask
private int mask(int spread)
-
copyTable
private void copyTable()
-
maxOccupiedWithData
private int maxOccupiedWithData()
-
isNonSentinel
private static boolean isNonSentinel(char value)
-
-