public class UnOrdListIntSet extends ListBasedIntSet { public UnOrdListIntSet() { super(); } /* * Return a new empty set, of the same implementation as "this" one */ protected IntSet newEmptySet() { return new UnOrdListIntSet(); } /* A helper method to locate the List container of an int */ protected List locate(int n) { List finger = list; while (finger != null) { int i = getInt(finger); if (i == n) return(finger); finger = finger.getRest(); } return null; } public void insert(int n) { if (locate(n) == null) { list = new List(new Integer(n), list); } } public void delete(int n) { List lookup = locate(n); if (lookup != null) { lookup.exchange(list.find(1)); list = list.getRest(); } } public static void main(String args[]) { UnOrdListIntSet uols = new UnOrdListIntSet(); uols.selfTest(); } }