@Generated(value="Autogenerated by OpenJAX CodeGen Template (0.2.5)", date="2020-05-23") public class HashCharSet extends HashPrimitiveSet implements CharSet
CharSet
implementing
open-addressing
(closed hashing) with linear-probing for collision resolution algorithm,
with allocation-free operation in steady state when expanded.
This class replicates the API of the HashSet
class by
defining synonymous methods for a set of char
values instead of
Object references.
Constructor and Description |
---|
HashCharSet()
Creates an empty
HashCharSet with the default initial capacity
(16) and the default load factor (0.55). |
HashCharSet(CharCollection c)
Creates a new
HashCharSet with the same values as the specified
collection. |
HashCharSet(Collection<Character> c)
Creates a new
HashCharSet with the same values as the specified
collection. |
HashCharSet(int initialCapacity)
Creates an empty
HashCharSet with the specified initial capacity and
the default load factor (0.55). |
HashCharSet(int initialCapacity,
float loadFactor)
Creates an empty
HashCharSet with the specified initial capacity and
load factor. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(char value)
Adds the specified value to this set if it is not already present.
|
boolean |
addAll(CharCollection c)
Adds all of the values in the specified collection to this set if they're
not already present.
|
boolean |
addAll(Collection<Character> c)
Adds all of the values in the specified collection to this set if they're
not already present.
|
boolean |
addAll(HashCharSet s)
Adds all of the values in the specified set to this set if they're not
already present.
|
void |
clear()
Removes all of the values from this set.
|
HashCharSet |
clone() |
void |
compact()
Compact the backing arrays by rehashing with a capacity just larger than
current size and giving consideration to the load factor.
|
boolean |
contains(char value)
Returns
true if this set contains the specified value. |
boolean |
containsAll(CharCollection c)
Returns
true if this set contains all of the values of the
specified collection. |
boolean |
containsAll(Collection<Character> c)
Returns
true if this set contains all of the values of the
specified collection. |
boolean |
equals(Object obj)
Compares the specified object with this set for equality.
|
int |
hashCode()
Returns the hash code value for this set.
|
boolean |
isEmpty()
Returns
true if this set contains no values. |
CharIterator |
iterator()
Returns an iterator over the values in this set.
|
boolean |
remove(char value)
Removes the specified value from this set if it is present.
|
boolean |
removeAll(char... a)
Removes all of this collection's values that are also contained in the
specified vararg array.
|
boolean |
removeAll(CharCollection c)
Removes from this set all of its values that are contained in the specified
collection.
|
boolean |
removeAll(Collection<Character> c)
Removes from this set all of its values that are contained in the specified
collection.
|
boolean |
removeAll(HashCharSet s)
Removes from this set all of its values that are contained in the specified
set.
|
boolean |
retainAll(CharCollection c)
Retains only the values in this set that are contained in the specified
collection.
|
boolean |
retainAll(Collection<Character> c)
Retains only the values in this set that are contained in the specified
collection.
|
int |
size()
Returns the number of values in this set (its cardinality).
|
char[] |
toArray(char[] a)
Returns an array containing all of the values in this collection in proper
sequence (from first to last value).
|
Character[] |
toArray(Character[] a)
Returns an array containing all of the values in this collection in proper
sequence (from first to last value).
|
String |
toString() |
findNextPositivePowerOfTwo, hash, nextIndex
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, removeIf, toArray
public HashCharSet()
HashCharSet
with the default initial capacity
(16) and the default load factor (0.55).public HashCharSet(int initialCapacity, float loadFactor)
HashCharSet
with the specified initial capacity and
load factor.initialCapacity
- The initial capacity.loadFactor
- The load factor.IllegalArgumentException
- If the initial capacity is negative or the
load factor less than .1
or greater than .9
.public HashCharSet(int initialCapacity)
HashCharSet
with the specified initial capacity and
the default load factor (0.55).initialCapacity
- The initial capacity.IllegalArgumentException
- If the initial capacity is negative.public HashCharSet(CharCollection c)
HashCharSet
with the same values as the specified
collection. The HashCharSet
is created with default load factor
(0.55) and an initial capacity sufficient to hold the mappings in the
specified collection.c
- The collection whose values are to be added to this set.NullPointerException
- If the specified set is null.public HashCharSet(Collection<Character> c)
HashCharSet
with the same values as the specified
collection. The HashCharSet
is created with default load factor
(0.55) and an initial capacity sufficient to hold the mappings in the
specified collection.c
- The collection whose values are to be added to this set.NullPointerException
- If the specified set is null.public boolean add(char value)
CharSet
value
to this set if the set
contains no value value2
such that value == value2
. If this
set already contains the value, the call leaves the set unchanged and
returns false
. In combination with the restriction on constructors,
this ensures that sets never contain duplicate values.add
in interface CharCollection
add
in interface CharSet
value
- Value to be added to this set.true
if this set did not already contain the specified
value.public boolean addAll(CharCollection c)
CharSet
addAll
operation effectively modifies this set so that its value is
the union of the two sets. The behavior of this operation is
undefined if the specified collection is modified while the operation is in
progress.addAll
in interface CharCollection
addAll
in interface CharSet
c
- Collection containing values to be added to this set.true
if this set changed as a result of the call.CharSet.addAll(Collection)
,
CharSet.add(char)
public boolean addAll(Collection<Character> c)
CharSet
addAll
operation effectively modifies this set so that its value is
the union of the two sets. The behavior of this operation is
undefined if the specified collection is modified while the operation is in
progress.addAll
in interface CharCollection
addAll
in interface CharSet
c
- Collection containing values to be added to this set.true
if this set changed as a result of the call.CharSet.addAll(CharCollection)
,
CharSet.add(char)
public boolean addAll(HashCharSet s)
addAll
operation effectively modifies this set
so that its value is the union of the two sets. The behavior of this
operation is undefined if the specified collection is modified while the
operation is in progress.s
- Set containing values to be added to this set.true
if this set changed as a result of the call.NullPointerException
- If the specified set is null.addAll(CharCollection)
,
add(char)
public boolean contains(char value)
CharSet
true
if this set contains the specified value. More
formally, returns true
if and only if this set contains a value
v
such that Objects.equals(value, v)
.contains
in interface CharCollection
contains
in interface CharSet
value
- Value whose presence in this set is to be tested.true
if this set contains the specified value.public boolean containsAll(CharCollection c)
CharSet
true
if this set contains all of the values of the
specified collection. If the specified collection is also a set, this
method returns true
if it is a subset of this set.containsAll
in interface CharCollection
containsAll
in interface CharSet
c
- Collection to be checked for containment in this set.true
if this set contains all of the values of the
specified collection.CharSet.containsAll(Collection)
,
CharSet.contains(char)
public boolean containsAll(Collection<Character> c)
CharSet
true
if this set contains all of the values of the
specified collection. If the specified collection is also a set, this
method returns true
if it is a subset of this set.containsAll
in interface CharCollection
containsAll
in interface CharSet
c
- Collection to be checked for containment in this set.true
if this set contains all of the values of the
specified collection.CharSet.containsAll(CharCollection)
,
CharSet.contains(char)
public boolean remove(char value)
CharSet
v
such that Objects.equals(value, v)
, if
this set contains such an value. Returns true
if this set contained
the value (or equivalently, if this set changed as a result of the call).
(This set will not contain the value once the call returns).remove
in interface CharCollection
remove
in interface CharSet
value
- Value to be removed from this set, if present.true
if this set contained the specified value.public boolean removeAll(char... a)
CharCollection
removeAll
in interface CharCollection
a
- Array containing values to be removed from this collection.true
if this collection changed as a result of the call.CharCollection.remove(char)
,
CharCollection.contains(char)
public boolean removeAll(CharCollection c)
CharSet
removeAll
in interface CharCollection
removeAll
in interface CharSet
c
- Collection containing values to be removed from this set.true
if this set changed as a result of the call.CharSet.removeAll(Collection)
,
CharSet.remove(char)
,
CharSet.contains(char)
public boolean removeAll(Collection<Character> c)
CharSet
removeAll
in interface CharCollection
removeAll
in interface CharSet
c
- Collection containing values to be removed from this set.true
if this set changed as a result of the call.CharSet.removeAll(CharCollection)
,
CharSet.remove(char)
,
CharSet.contains(char)
public boolean removeAll(HashCharSet s)
s
- Set containing values to be removed from this set.true
if this set changed as a result of the call.NullPointerException
- If the specified collection is null.removeAll(CharCollection)
,
remove(char)
,
contains(char)
public boolean retainAll(CharCollection c)
CharSet
retainAll
in interface CharCollection
retainAll
in interface CharSet
c
- Collection containing values to be retained in this set.true
if this set changed as a result of the call.CharSet.retainAll(Collection)
,
CharSet.remove(char)
,
CharSet.contains(char)
public boolean retainAll(Collection<Character> c)
CharSet
retainAll
in interface CharCollection
retainAll
in interface CharSet
c
- Collection containing values to be retained in this set.true
if this set changed as a result of the call.CharSet.retainAll(CharCollection)
,
CharSet.remove(char)
,
CharSet.contains(char)
public void clear()
CharSet
clear
in interface CharSet
clear
in interface PrimitiveCollection
public int size()
CharSet
Character.MAX_VALUE
values, returns
Character.MAX_VALUE
.size
in interface CharSet
size
in interface PrimitiveCollection
public boolean isEmpty()
CharSet
true
if this set contains no values.isEmpty
in interface CharSet
isEmpty
in interface PrimitiveCollection
true
if this set contains no values.public char[] toArray(char[] a)
CharCollection
If the collection fits in the specified array with room to spare (i.e., the
array has more values than the collection), the value in the array
immediately following the end of the collection is set to 0
. (This
is useful in determining the length of the collection only if the
caller knows that the collection does not contain any 0
values).
toArray
in interface CharCollection
a
- The array into which the values of the collection are to be
stored. If the array is not big enough to store the values, a new
array is allocated.public Character[] toArray(Character[] a)
CharCollection
If the collection fits in the specified array with room to spare (i.e., the array has more values than the collection), the value in the array immediately following the end of the collection is set to null.
toArray
in interface CharCollection
a
- The array into which the values of the collection are to be
stored. If the array is not big enough to store the values, a new
array is allocated.public CharIterator iterator()
CharSet
iterator
in interface CharIterable
iterator
in interface CharSet
public void compact()
public HashCharSet clone()
public boolean equals(Object obj)
CharSet
true
if the specified object is also a set, the two sets have the
same size, and every member of the specified set is contained in this set
(or equivalently, every member of this set is contained in the specified
set). This definition ensures that the equals method works properly across
different implementations of the set interface.equals
in interface CharSet
equals
in interface PrimitiveCollection
equals
in class Object
obj
- Object to be compared for equality with this set.true
if the specified object is equal to this set.Object.equals(Object)
,
IntSet.equals(Object)
,
IntList.equals(Object)
public int hashCode()
CharSet
s1 == s2
implies that s1.hashCode() == s2.hashCode()
for
any two sets s1
and s2
, as required by the general contract
of Object.hashCode()
.hashCode
in interface CharSet
hashCode
in interface PrimitiveCollection
hashCode
in class Object
Object.equals(Object)
,
CharSet.equals(Object)
Copyright © 2020 LibJ. All rights reserved.