Package org.jboss.weld.util.collections
Class ArraySet<E>
- java.lang.Object
-
- org.jboss.weld.util.collections.ArraySet<E>
-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Set<E>
public class ArraySet<E> extends Object implements Set<E>, Serializable
A
Setwhich 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.
- Author:
- David Allen
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)booleanaddAll(E... elements)booleanaddAll(Collection<? extends E> otherCollection)List<E>asList()voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanequals(Object obj)inthashCode()booleanisEmpty()Iterator<E>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<T> T[]toArray(T[] a)StringtoString()ArraySet<E>trimToSize()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
ArraySet
public ArraySet(Collection<E> initialElements)
-
ArraySet
public ArraySet(int size)
-
ArraySet
public ArraySet()
-
ArraySet
public ArraySet(E... initialElements)
-
ArraySet
public ArraySet(Collection<E> initialElements, E... initialElements2)
-
-
Method Detail
-
add
public boolean add(E e)
-
addAll
public boolean addAll(Collection<? extends E> otherCollection)
-
addAll
public boolean addAll(E... elements)
-
clear
public void clear()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
isEmpty
public boolean isEmpty()
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
size
public int size()
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
-