/** * Description: Works just like java.util.ArrayList, except it will refuse to * add an element if it is equal to an element already appearing in the * ArrayListSet. In other words, it's an ArrayList which maintains uniqueness * like java.util.Set does. * * @author Kerry M. Soileau *
 * ksoileau@wt.net
 * http://web.wt.net/~ksoileau/index.htm
 * 
* @version 1.3 */ import java.util.*; public class ArrayListSet extends ArrayList implements Set { /** * Constructs a new, empty ArrayListSet. */ public ArrayListSet() { } /** * Constructs a new set containing space for the specified number of objects. * * @param n The capacity of the new set. */ public ArrayListSet(int n) { super(n); } /** * Constructs a new set containing the elements in the specified * collection. * * @param c The elements that will comprise the new set. */ public ArrayListSet(Collection c) { addAll(c); } /** * Adds the specified element to this set if it is not already present. * * @param o element to be added to this set. * @return true if the set did not already contain the specified * element. */ public boolean add(Object o) { for(int i=0;itrue if this set changed as a result of the call. */ public boolean addAll(Collection c) { boolean changed=false; if (c.size() > 0) { Iterator it=c.iterator(); while(it.hasNext()) { Object nextobj=it.next(); boolean res=this.add(nextobj); if(res) changed=true; } } return changed; } /** * Adds the specified element to this set if it is not already present. * * @param o element to be added to this set. */ public void addElement(Object o) { for(int i=0;i