E
- The type of elements in this ArraySetpublic class ArraySet<E>
extends java.lang.Object
implements java.util.Set<E>
An ArraySet is a Set implemented as a resizable array, just like that of an ArrayList. An ArraySet takes up less memory than other Set types, and offers at-least-comparable performance to a HashSet when the Set size is very small. For best results, the initial capacity of an ArraySet should be set to the smallest number that the ArraySet's size will almost certainly never exceed.
ArrayList
Constructor and Description |
---|
ArraySet()
Constructs an empty ArraySet with an initial capacity of 10.
|
ArraySet(java.util.Collection<? extends E> c)
Constructs an ArraySet containing the elements of the specified
Collection.
|
ArraySet(int initialCapacity)
Constructs an empty ArraySet with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
boolean |
addAll(java.util.Collection<? extends E> c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this ArraySet, if necessary, to be at least the
specified minimum capacity.
|
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
void |
trimToSize()
Trims the capacity of this ArraySet to be equal to its current size.
|
public ArraySet(int initialCapacity)
initialCapacity
- The initial capacity of the ArraySetpublic ArraySet()
public ArraySet(java.util.Collection<? extends E> c)
c
- The Collection whose elements are to be placed into this
ArraySetpublic int size()
public boolean isEmpty()
public boolean contains(java.lang.Object o)
public java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean add(E e)
public boolean remove(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean addAll(java.util.Collection<? extends E> c)
public boolean retainAll(java.util.Collection<?> c)
public boolean removeAll(java.util.Collection<?> c)
public void clear()
public final void trimToSize()
public final void ensureCapacity(int minCapacity)
minCapacity
- The minimum capacity that this ArraySet should have