org.jboss.weld.util.collections
Class ArraySet<E>

java.lang.Object
  extended by 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 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.

Author:
David Allen
See Also:
Serialized Form

Constructor Summary
ArraySet()
           
ArraySet(ArrayList<E> initialList)
           
ArraySet(Collection<E> initialElements)
           
ArraySet(int size)
           
 
Method Summary
 boolean add(E e)
           
 boolean addAll(Collection<? extends E> otherCollection)
           
 List<E> asList()
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean equals(Object obj)
           
 int hashCode()
           
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 int size()
           
 Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 String toString()
           
 ArraySet<E> trimToSize()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArraySet

public ArraySet(ArrayList<E> initialList)

ArraySet

public ArraySet(Collection<E> initialElements)

ArraySet

public ArraySet(int size)

ArraySet

public ArraySet()
Method Detail

add

public boolean add(E e)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>

addAll

public boolean addAll(Collection<? extends E> otherCollection)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>

asList

public List<E> asList()

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface Set<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface Set<E>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface Set<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>

trimToSize

public ArraySet<E> trimToSize()

equals

public boolean equals(Object obj)
Specified by:
equals in interface Collection<E>
Specified by:
equals in interface Set<E>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface Set<E>
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Seam Framework. All Rights Reserved.