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 class
CharHashSet.ImmutableCharHashSet
private class
CharHashSet.InternalCharIterator
-
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 char
EMPTY
private static int
INITIAL_LINEAR_PROBE
private static int
KEY_SIZE
private int
occupiedWithData
private int
occupiedWithSentinels
private static char
REMOVED
private static long
serialVersionUID
private char[]
table
private int
zeroToThirtyOne
private int
zeroToThirtyOneOccupied
-
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 Modifier and Type Method Description boolean
add(char element)
boolean
addAll(char... source)
boolean
addAll(CharIterable source)
protected void
allocateTable(int sizeToAllocate)
boolean
allSatisfy(CharPredicate predicate)
Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(CharPredicate predicate)
Returns true if any of the elements in the CharIterable 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
.MutableCharSet
asSynchronized()
MutableCharSet
asUnmodifiable()
MutableCharIterator
charIterator()
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.void
clear()
<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.void
compact()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels.boolean
contains(char value)
Returns true if the value is contained in the CharIterable, and false if it is not.private void
copyTable()
int
count(CharPredicate predicate)
Returns a count of the number of elements in the CharIterable that return true for the specified predicate.char
detectIfNone(CharPredicate predicate, char ifNone)
void
each(CharProcedure procedure)
A synonym for forEach.CharSet
freeze()
Returns a frozen copy of this set.int
hashCode()
Follows the same general contract asSet.hashCode()
.<T> T
injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)
private static boolean
isBetweenZeroAndThirtyOne(char value)
private static boolean
isNonSentinel(char value)
private int
mask(int spread)
char
max()
private int
maxOccupiedWithData()
char
min()
CharHashSet
newEmpty()
Creates a new empty CharHashSet.static CharHashSet
newSet(CharIterable source)
static CharHashSet
newSetWith(char... source)
(package private) int
probe(char element)
(package private) int
probeThree(char element, int removedIndex)
(package private) int
probeTwo(char element, int removedIndex)
void
readExternal(java.io.ObjectInput in)
private void
rehash(int newCapacity)
private void
rehashAndGrow()
CharHashSet
reject(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.boolean
remove(char value)
boolean
removeAll(char... source)
boolean
removeAll(CharIterable source)
private boolean
removeZeroToThirtyOne(char value)
boolean
retainAll(char... source)
boolean
retainAll(CharIterable source)
CharHashSet
select(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.int
size()
Returns the number of items in this iterable.private int
smallestPowerOfTwoGreaterThan(int n)
(package private) int
spreadAndMask(char element)
(package private) int
spreadTwoAndMask(char element)
long
sum()
char[]
toArray()
Converts the CharIterable to a primitive char array.char[]
toArray(char[] array)
Converts the CharIterable to a primitive char array.ImmutableCharSet
toImmutable()
Returns an immutable copy of this set.CharHashSet
with(char element)
CharHashSet
withAll(CharIterable elements)
CharHashSet
without(char element)
CharHashSet
withoutAll(CharIterable elements)
void
writeExternal(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
-
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:CharSet
Follows the same general contract asSet.hashCode()
.- Specified by:
hashCode
in interfaceCharSet
- Specified by:
hashCode
in classAbstractCharSet
-
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(char element)
- Specified by:
add
in interfaceMutableCharCollection
-
addAll
public boolean addAll(char... source)
- Specified by:
addAll
in interfaceMutableCharCollection
-
addAll
public boolean addAll(CharIterable source)
- Specified by:
addAll
in interfaceMutableCharCollection
-
remove
public boolean remove(char value)
- Specified by:
remove
in interfaceMutableCharCollection
-
removeZeroToThirtyOne
private boolean removeZeroToThirtyOne(char value)
-
removeAll
public boolean removeAll(CharIterable source)
- Specified by:
removeAll
in interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source)
- Specified by:
removeAll
in interfaceMutableCharCollection
-
retainAll
public boolean retainAll(CharIterable source)
- Specified by:
retainAll
in interfaceMutableCharCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(char... source)
- Specified by:
retainAll
in interfaceMutableCharCollection
- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableCharCollection
-
with
public CharHashSet with(char element)
- Specified by:
with
in interfaceMutableCharCollection
- Specified by:
with
in interfaceMutableCharSet
-
without
public CharHashSet without(char element)
- Specified by:
without
in interfaceMutableCharCollection
- Specified by:
without
in interfaceMutableCharSet
-
withAll
public CharHashSet withAll(CharIterable elements)
- Specified by:
withAll
in interfaceMutableCharCollection
- Specified by:
withAll
in interfaceMutableCharSet
-
withoutAll
public CharHashSet withoutAll(CharIterable elements)
- Specified by:
withoutAll
in interfaceMutableCharCollection
- Specified by:
withoutAll
in interfaceMutableCharSet
-
asUnmodifiable
public MutableCharSet asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableCharCollection
- Specified by:
asUnmodifiable
in interfaceMutableCharSet
-
asSynchronized
public MutableCharSet asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableCharCollection
- Specified by:
asSynchronized
in interfaceMutableCharSet
-
toImmutable
public ImmutableCharSet toImmutable()
Description copied from interface:MutableCharSet
Returns an immutable copy of this set.- Specified by:
toImmutable
in interfaceCharSet
- Specified by:
toImmutable
in interfaceMutableCharCollection
- Specified by:
toImmutable
in interfaceMutableCharSet
-
charIterator
public MutableCharIterator charIterator()
Description copied from interface:CharIterable
Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIterator
in interfaceCharIterable
- Specified by:
charIterator
in interfaceMutableCharCollection
-
toArray
public char[] toArray()
Description copied from interface:CharIterable
Converts the CharIterable to a primitive char array.- Specified by:
toArray
in interfaceCharIterable
-
toArray
public char[] toArray(char[] array)
Description copied from interface:CharIterable
Converts 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:
toArray
in interfaceCharIterable
-
contains
public boolean contains(char value)
Description copied from interface:CharIterable
Returns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
contains
in interfaceCharIterable
-
each
public void each(CharProcedure procedure)
Description copied from interface:CharIterable
A synonym for forEach.- Specified by:
each
in interfaceCharIterable
- Since:
- 7.0.
-
select
public CharHashSet select(CharPredicate predicate)
Description copied from interface:CharIterable
Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
select
in interfaceCharIterable
- Specified by:
select
in interfaceCharSet
- Specified by:
select
in interfaceMutableCharCollection
- Specified by:
select
in interfaceMutableCharSet
-
select
public <R extends MutableCharCollection> R select(CharPredicate predicate, R target)
Description copied from interface:CharIterable
Same asCharIterable.select(CharPredicate)
, only the results are added to the target MutableCharCollection.- Specified by:
select
in interfaceCharIterable
- Since:
- 8.1.
-
reject
public CharHashSet reject(CharPredicate predicate)
Description copied from interface:CharIterable
Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
reject
in interfaceCharIterable
- Specified by:
reject
in interfaceCharSet
- Specified by:
reject
in interfaceMutableCharCollection
- Specified by:
reject
in interfaceMutableCharSet
-
reject
public <R extends MutableCharCollection> R reject(CharPredicate predicate, R target)
Description copied from interface:CharIterable
Same asCharIterable.reject(CharPredicate)
, only the results are added to the target MutableCharCollection.- Specified by:
reject
in interfaceCharIterable
- Since:
- 8.1.
-
collect
public <V> MutableSet<V> collect(CharToObjectFunction<? extends V> function)
Description copied from interface:CharIterable
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 interfaceCharIterable
- Specified by:
collect
in interfaceCharSet
- Specified by:
collect
in interfaceMutableCharCollection
- Specified by:
collect
in interfaceMutableCharSet
-
collect
public <V,R extends java.util.Collection<V>> R collect(CharToObjectFunction<? extends V> function, R target)
Description copied from interface:CharIterable
Same asCharIterable.collect(CharToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceCharIterable
- Since:
- 8.1.
-
detectIfNone
public char detectIfNone(CharPredicate predicate, char ifNone)
- Specified by:
detectIfNone
in interfaceCharIterable
-
count
public int count(CharPredicate predicate)
Description copied from interface:CharIterable
Returns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
count
in interfaceCharIterable
-
anySatisfy
public boolean anySatisfy(CharPredicate predicate)
Description copied from interface:CharIterable
Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceCharIterable
-
allSatisfy
public boolean allSatisfy(CharPredicate predicate)
Description copied from interface:CharIterable
Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceCharIterable
-
sum
public long sum()
- Specified by:
sum
in interfaceCharIterable
-
max
public char max()
- Specified by:
max
in interfaceCharIterable
-
min
public char min()
- Specified by:
min
in interfaceCharIterable
-
freeze
public CharSet freeze()
Description copied from interface:MutableCharSet
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 interfaceCharSet
- Specified by:
freeze
in interfaceMutableCharSet
-
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, ObjectCharToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceCharIterable
-
chunk
public RichIterable<CharIterable> chunk(int size)
Description copied from interface:CharIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceCharIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingCharIterable
s 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:
newEmpty
in interfaceMutableCharCollection
- Specified by:
newEmpty
in interfaceMutableCharSet
- 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(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)
-
-