edu.stanford.nlp.util
Class ArraySet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by edu.stanford.nlp.util.ArraySet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

public class ArraySet<E>
extends java.util.AbstractSet<E>

An array-backed set.

Author:
Roger Levy (rog@stanford.edu)

Constructor Summary
ArraySet()
          Constructs an ArraySet.
ArraySet(E... elements)
          Constructs an ArraySet with the specified elements.
ArraySet(int initialSize)
          Constructs an ArraySet with specified initial size of backing array.
 
Method Summary
 boolean add(E e)
          Adds element to set.
 java.util.Iterator<E> iterator()
          Returns iterator over elements of the set.
 int size()
          Returns size of set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray
 

Constructor Detail

ArraySet

public ArraySet()
Constructs an ArraySet.


ArraySet

public ArraySet(int initialSize)
Constructs an ArraySet with specified initial size of backing array.

Parameters:
initialSize - initial size of the backing array.

ArraySet

public ArraySet(E... elements)
Constructs an ArraySet with the specified elements.

Parameters:
elements - the elements to be put in the set.
Method Detail

iterator

public java.util.Iterator<E> iterator()
Returns iterator over elements of the set.

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>
Specified by:
iterator in class java.util.AbstractCollection<E>

add

public boolean add(E e)
Adds element to set.

Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.Set<E>
Overrides:
add in class java.util.AbstractCollection<E>
Parameters:
e - the element to be added.
Returns:
false if the set already contained (vis. .equals()) the specified element; true otherwise.

size

public int size()
Returns size of set.

Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.Set<E>
Specified by:
size in class java.util.AbstractCollection<E>
Returns:
number of elements in set.


Stanford NLP Group