public class ArraySet<E> extends AbstractSet<E> implements Set<E>
Modifier and Type | Class and Description |
---|---|
static class |
ArraySet.SetFullException |
Modifier and Type | Field and Description |
---|---|
protected Object[] |
_entries |
static int |
MAX_CAPACITY |
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) |
protected int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<E> |
iterator()
Supports remove.
|
boolean |
remove(Object o) |
int |
size() |
equals, hashCode, removeAll
addAll, containsAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, equals, hashCode, removeAll, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public static final int MAX_CAPACITY
protected final Object[] _entries
public ArraySet()
public ArraySet(Set<? extends E> c)
public ArraySet(Set<? extends E> c, int capacity)
public ArraySet(Collection<? extends E> c)
public ArraySet(Collection<? extends E> c, int capacity)
public ArraySet(E[] arr)
public ArraySet(int capacity)
capacity
- the maximum sizeIllegalArgumentException
- if capacity less than 1.public ArraySet(int capacity, boolean throwOnFull)
capacity
- the maximum sizeIllegalArgumentException
- if capacity less than 1.protected int indexOf(Object o)
public boolean add(E o)
add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
ArraySet.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 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>
public E get(int index)
IndexOutOfBoundsException