public class ArraySet<E>
extends java.lang.Object
implements java.util.Set<E>, java.io.Serializable
A Set which is backed by a simple array of elements. This provides
all the behaviors of a set backed by an array, thus insert and remove
operations are always O(n) time to check for uniqueness. This should only be
used for sets which are known to be mostly empty or to contain only a handful
of elements.
The primary use of this set is for those cases where small sets exists and will not be changed. The savings in memory is significant compared to hash sets which may contain many empty buckets.
| Constructor and Description |
|---|
ArraySet() |
ArraySet(java.util.ArrayList<E> initialList) |
ArraySet(java.util.Collection<E> initialElements) |
ArraySet(java.util.Collection<E> initialElements,
E... initialElements2) |
ArraySet(E... initialElements) |
ArraySet(int size) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(java.util.Collection<? extends E> otherCollection) |
boolean |
addAll(E... elements) |
java.util.List<E> |
asList() |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
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) |
java.lang.String |
toString() |
ArraySet<E> |
trimToSize() |
public ArraySet(java.util.ArrayList<E> initialList)
public ArraySet(java.util.Collection<E> initialElements)
public ArraySet(int size)
public ArraySet()
public ArraySet(E... initialElements)
public boolean add(E e)
public boolean addAll(java.util.Collection<? extends E> otherCollection)
public boolean addAll(E... elements)
public java.util.List<E> asList()
public void clear()
public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean isEmpty()
public java.util.Iterator<E> iterator()
public boolean remove(java.lang.Object o)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public int size()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean equals(java.lang.Object obj)
public int hashCode()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2015. All Rights Reserved.