public class ArraySet<E>extends Objectimplements Set<E>, Serializable
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|
|Modifier and Type||Method and Description|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public ArraySet(int size)
public ArraySet(E... initialElements)
public boolean add(E e)
public boolean addAll(Collection<? extends E> otherCollection)
public boolean addAll(E... elements)
public void clear()
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
public boolean isEmpty()
public boolean remove(Object o)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public int size()
public Object toArray()
public <T> T toArray(T a)
public boolean equals(Object obj)
public int hashCode()
Copyright © 2015. All Rights Reserved.