harpoon.Util.Collections
Class LinearSet

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractSet
              |
              +--harpoon.Util.Collections.LinearSet
All Implemented Interfaces:
Cloneable, Collection, Serializable, Set

public class LinearSet
extends AbstractSet
implements Cloneable, Serializable

LinearSet is a simplistic light-weight Set designed for use when the number of entries is small. It is backed by a List.

Version:
$Id: LinearSet.java,v 1.2 2002/02/25 21:09:05 cananian Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>
See Also:
Serialized Form

Constructor Summary
LinearSet()
          Creates a LinearSet.
LinearSet(int capacity)
          Creates a LinearSet with given capacity.
LinearSet(ListFactory lf)
          Creates an empty LinearSet, using a List generated by lf as the backing store.
LinearSet(ListFactory lf, int capacity)
          Creates an empty LinearSet with a given capacity, using a List generated by lf as the backing store.
LinearSet(ListFactory lf, Set set)
          Creates an empty LinearSet, using a List generated by lf as the backing store, and fills it with the elements of set.
LinearSet(Set set)
          Creates a LinearSet, filling it with the elements of set.
 
Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 Object clone()
           
 Iterator iterator()
           
 boolean remove(Object o)
           
 int size()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
clear, contains, containsAll, isEmpty, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
clear, contains, containsAll, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

LinearSet

public LinearSet()
Creates a LinearSet. Uses an ArrayList as the backing store.


LinearSet

public LinearSet(int capacity)
Creates a LinearSet with given capacity. Uses an ArrayList as the backing store.


LinearSet

public LinearSet(Set set)
Creates a LinearSet, filling it with the elements of set. Uses an ArrayList as the backing store.


LinearSet

public LinearSet(ListFactory lf)
Creates an empty LinearSet, using a List generated by lf as the backing store.


LinearSet

public LinearSet(ListFactory lf,
                 int capacity)
Creates an empty LinearSet with a given capacity, using a List generated by lf as the backing store.


LinearSet

public LinearSet(ListFactory lf,
                 Set set)
Creates an empty LinearSet, using a List generated by lf as the backing store, and fills it with the elements of set.

Method Detail

iterator

public Iterator iterator()
Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection

size

public int size()
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection

add

public boolean add(Object o)
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Set
Overrides:
addAll in class AbstractCollection

remove

public boolean remove(Object o)
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection

clone

public Object clone()
Overrides:
clone in class Object