E - type of elements in this setpublic class ArraySet<E> extends AbstractSet<E> implements Set<E>
| Modifier and Type | Class and Description |
|---|---|
static class | ArraySet.SetFullExceptionException thrown when attempting to add an element to a full ArraySet. |
| Modifier and Type | Field and Description |
|---|---|
protected Object[] | _entriesThe underlying array of entries |
static int | MAX_CAPACITYThe maximum capacity for this set |
| Constructor and Description |
|---|
ArraySet()A fixed capacity of MAX_CAPACITY. |
ArraySet(Collection<? extends E> c)A fixed capacity of max(MAX_CAPACITY, c.size()), which may be more than
the resulting set size if there are duplicates in c. |
ArraySet(Collection<? extends E> c,
int capacity)A fixed capacity of max(capacity, c.size()), which may be more than
the resulting set size if there are duplicates in c. |
ArraySet(E[] arr)A fixed capacity of arr.length. |
ArraySet(int capacity)Adds over capacity will throw a SetFullException. |
ArraySet(int capacity,
boolean throwOnFull)If throwOnFull is false,
adds over capacity will overwrite starting at slot zero. |
ArraySet(Set<? extends E> c)A fixed capacity of max(MAX_CAPACITY, c.size())
Adds over capacity will throw a SetFullException. |
ArraySet(Set<? extends E> c,
int capacity)A fixed capacity of max(capacity, c.size())
Adds over capacity will throw a SetFullException. |
| Modifier and Type | Method and Description |
|---|---|
boolean | add(E o) |
void | addUnique(E o)Unconditionally add o to the set. |
void | clear() |
boolean | contains(Object o) |
E | get(int index)Returns the element at the specified index. |
protected int | indexOf(Object o)Finds the index of the given object in the set. |
boolean | isEmpty() |
Iterator<E> | iterator()Supports remove. |
boolean | remove(Object o) |
int | size() |
equals, hashCode, removeAlladdAll, containsAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, removeAll, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streamprotected final Object[] _entries
public static final int MAX_CAPACITY
public ArraySet()
public ArraySet(Collection<? extends E> c)
c - the collection to copypublic ArraySet(Collection<? extends E> c, int capacity)
c - the collection to copycapacity - the maximum capacitypublic ArraySet(E[] arr)
arr - the array to copypublic ArraySet(int capacity)
capacity - the maximum sizeIllegalArgumentException - if capacity less than 1.public ArraySet(int capacity,
boolean throwOnFull)capacity - the maximum sizethrowOnFull - whether to throw on overflowIllegalArgumentException - if capacity less than 1.public ArraySet(Set<? extends E> c)
c - the collection to copypublic boolean add(E o)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>o - the element to addArraySet.SetFullException - if throwOnFull was true in constructorNullPointerException - if o is nullpublic void addUnique(E o)
o - non-null, NPE will not be thrownArraySet.SetFullException - if throwOnFull was true in constructorpublic void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public E get(int index)
index - the indexIndexOutOfBoundsException - if index is out of boundsprotected int indexOf(Object o)
o - the object to find the index ofpublic boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>public int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>