Set implementation with closed hashing (open addressing).
| Modifier and Type | Class and Description |
|---|---|
| protected class |
| Modifier and Type | Field and Description |
|---|---|
| protected T[][] | |
| protected final AbstractEqualityComparator | |
| protected int | |
| public static final int | |
| public static final int | |
| protected int | |
| public static final double | |
| protected int | n
How many elements in set |
| protected int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | Array2DHashSet(AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity)
|
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | add(T
element to be added to this set t)Implements java. |
| public boolean | addAll(Collection<? extends T>
collection containing elements to be added to this set c)Implements java. |
| protected T | Returns: o if it could be an instance of T, otherwise
null.the object to try and cast to the element type of the set o)Return |
| public void | clear()
Implements java. |
| public final boolean | contains(Object
element whose presence in this set is to be tested o)Implements java. true if this set contains the specified element.
|
| public boolean | containsAll(Collection<?>
collection to be checked for containment in this set collection)Implements java. true if this set contains all of the elements of the
specified collection.
|
| public boolean | |
| protected T[] | Returns: the newly constructed arraythe length of the array to return capacity)Return an array of |
| protected T[][] | Returns: the newly constructed arraythe length of the array to return capacity)Return an array of |
| public boolean | equals(Object
object to be compared for equality with this set o)Overrides java. Implements java. |
| protected void | |
| public T | |
| protected final int | |
| public final T | |
| protected T | |
| public int | hashCode()
Overrides java. Implements java. |
| public final boolean | |
| public Iterator | |
| public final boolean | remove(Object
object to be removed from this set, if present o)Implements java. |
| public boolean | removeAll(Collection<?>
collection containing elements to be removed from this set c)Implements java. |
| public boolean | |
| public boolean | retainAll(Collection<?>
collection containing elements to be retained in this set c)Implements java. |
| public final int | |
| public T[] | toArray()
Implements java. |
| public <U> U[] | toArray(U[]
the array into which the elements of this set are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose. a)Implements java. |
| public String | |
| public String |
| buckets | back to summary |
|---|---|
| protected T[][] buckets | |
| comparator | back to summary |
|---|---|
| protected final AbstractEqualityComparator<? super T> comparator
| |
| currentPrime | back to summary |
|---|---|
| protected int currentPrime | |
| INITAL_BUCKET_CAPACITY | back to summary |
|---|---|
| public static final int INITAL_BUCKET_CAPACITY | |
| INITAL_CAPACITY | back to summary |
|---|---|
| public static final int INITAL_CAPACITY | |
| initialBucketCapacity | back to summary |
|---|---|
| protected int initialBucketCapacity | |
| LOAD_FACTOR | back to summary |
|---|---|
| public static final double LOAD_FACTOR | |
| n | back to summary |
|---|---|
| protected int n How many elements in set | |
| threshold | back to summary |
|---|---|
| protected int threshold | |
| Array2DHashSet | back to summary |
|---|---|
| public Array2DHashSet() | |
| Array2DHashSet | back to summary |
|---|---|
| public Array2DHashSet(AbstractEqualityComparator<? super T> comparator) | |
| Array2DHashSet | back to summary |
|---|---|
| public Array2DHashSet(AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity) | |
| add | back to summary |
|---|---|
| public final boolean add(T t) Implements java. Doc from java. Adds the specified element to this set if it is not already present
(optional operation). More formally, adds the specified element
The stipulation above does not imply that sets must accept all
elements; sets may refuse to add any particular element, including
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(Collection<? extends T> c) Implements java. Doc from java. Adds all of the elements in the specified collection to this set if
they're not already present (optional operation). If the specified
collection is also a set, the
| |
| asElementType | back to summary |
|---|---|
| protected T asElementType(Object o) Return
| |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the elements from this set (optional operation). The set will be empty after this call returns.
| |
| contains | back to summary |
|---|---|
| public final boolean contains(Object o) Implements java. Doc from java. Returns | |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(Collection<?> collection) Implements java. Doc from java. Returns
| |
| containsFast | back to summary |
|---|---|
| public boolean containsFast(T obj) | |
| createBucket | back to summary |
|---|---|
| protected T[] createBucket(int capacity) Return an array of
| |
| createBuckets | back to summary |
|---|---|
| protected T[][] createBuckets(int capacity) Return an array of
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this set for equality. Returns
| |
| expand | back to summary |
|---|---|
| protected void expand() | |
| get | back to summary |
|---|---|
| public T get(T o) | |
| getBucket | back to summary |
|---|---|
| protected final int getBucket(T o) | |
| getOrAdd | back to summary |
|---|---|
| public final T getOrAdd(T o) Add | |
| getOrAddImpl | back to summary |
|---|---|
| protected T getOrAddImpl(T o) | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this set. The hash code of a set is
defined to be the sum of the hash codes of the elements in the set,
where the hash code of a
| |
| isEmpty | back to summary |
|---|---|
| public final boolean isEmpty() Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee). | |
| remove | back to summary |
|---|---|
| public final boolean remove(Object o) Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element | |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> c) Implements java. Doc from java. Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
| |
| removeFast | back to summary |
|---|---|
| public boolean removeFast(T obj) | |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> c) Implements java. Doc from java. Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
| |
| size | back to summary |
|---|---|
| public final int size() Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| toArray | back to summary |
|---|---|
| public T[] toArray() Implements java. Doc from java. Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs.
| |
| toArray | back to summary |
|---|---|
| public <U> U[] toArray(U[] a) Implements java. Doc from java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set. If this set fits in the specified array with room to spare
(i.e., the array has more elements than this set), the element in
the array immediately following the end of the set is set to
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. Like the Suppose
String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to
toArray().
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| toTableString | back to summary |
|---|---|
| public String toTableString() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final T[] | |
| pack-priv int | |
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public T | |
| public void | remove()
Overrides default java. |
| data | back to summary |
|---|---|
| pack-priv final T[] data | |
| nextIndex | back to summary |
|---|---|
| pack-priv int nextIndex | |
| removed | back to summary |
|---|---|
| pack-priv boolean removed | |
| SetIterator | back to summary |
|---|---|
| public SetIterator(T[] data) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |