public class Array2DHashSet<T> extends Object implements Set<T>
Set
implementation with closed hashing (open addressing).Modifier and Type | Class and Description |
---|---|
protected class |
Array2DHashSet.SetIterator |
Modifier and Type | Field and Description |
---|---|
protected T[][] |
buckets |
protected AbstractEqualityComparator<? super T> |
comparator |
protected int |
currentPrime |
static int |
INITAL_BUCKET_CAPACITY |
static int |
INITAL_CAPACITY |
protected int |
initialBucketCapacity |
static double |
LOAD_FACTOR |
protected int |
n
How many elements in set
|
protected int |
threshold |
Constructor and Description |
---|
Array2DHashSet() |
Array2DHashSet(AbstractEqualityComparator<? super T> comparator) |
Array2DHashSet(AbstractEqualityComparator<? super T> comparator,
int initialCapacity,
int initialBucketCapacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T t) |
boolean |
addAll(Collection<? extends T> c) |
protected T |
asElementType(Object o)
Return
o as an instance of the element type T . |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> collection) |
boolean |
containsFast(T obj) |
protected T[] |
createBucket(int capacity)
Return an array of
T with length capacity . |
protected T[][] |
createBuckets(int capacity)
Return an array of
T[] with length capacity . |
boolean |
equals(Object o) |
protected void |
expand() |
T |
get(T o) |
protected int |
getBucket(T o) |
T |
getOrAdd(T o)
Add
o to set if not there; return existing value if already
there. |
protected T |
getOrAddImpl(T o) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeFast(T obj) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
T[] |
toArray() |
<U> U[] |
toArray(U[] a) |
String |
toString() |
String |
toTableString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
spliterator
parallelStream, removeIf, stream
public static final int INITAL_CAPACITY
public static final int INITAL_BUCKET_CAPACITY
public static final double LOAD_FACTOR
protected final AbstractEqualityComparator<? super T> comparator
protected T[][] buckets
protected int n
protected int threshold
protected int currentPrime
protected int initialBucketCapacity
public Array2DHashSet()
public Array2DHashSet(AbstractEqualityComparator<? super T> comparator)
public Array2DHashSet(AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity)
public final T getOrAdd(T o)
o
to set if not there; return existing value if already
there. This method performs the same operation as add(T)
aside from
the return value.protected final int getBucket(T o)
public int hashCode()
public boolean equals(Object o)
protected void expand()
public final boolean add(T t)
public final int size()
public final boolean isEmpty()
public final boolean contains(Object o)
public boolean containsFast(T obj)
public T[] toArray()
public <U> U[] toArray(U[] a)
public final boolean remove(Object o)
public boolean removeFast(T obj)
public boolean containsAll(Collection<?> collection)
containsAll
in interface Collection<T>
containsAll
in interface Set<T>
public boolean addAll(Collection<? extends T> c)
public boolean retainAll(Collection<?> c)
public boolean removeAll(Collection<?> c)
public void clear()
public String toTableString()
protected T asElementType(Object o)
o
as an instance of the element type T
. If
o
is non-null but known to not be an instance of T
, this
method returns null
. The base implementation does not perform any
type checks; override this method to provide strong type checks for the
contains(java.lang.Object)
and remove(java.lang.Object)
methods to ensure the arguments to
the EqualityComparator
for the set always have the expected
types.o
- the object to try and cast to the element type of the seto
if it could be an instance of T
, otherwise
null
.protected T[][] createBuckets(int capacity)
T[]
with length capacity
.capacity
- the length of the array to returnprotected T[] createBucket(int capacity)
T
with length capacity
.capacity
- the length of the array to returnCopyright © 1992-2015 ANTLR. All Rights Reserved.