// The list-based set public class LBS { protected ListOfObjects ls; public LBS() { ls = new ListOfObjects(); } public int sizeOf() { int ans = 0; ls.reset(); while (!ls.atEnd()) { ++ans; ls.next(); } return ans; } public boolean isEmpty() { return sizeOf() == 0; } public Element[] getContents() { Element[] ans = new Element[sizeOf()]; int loc = 0; ls.reset(); while (!ls.atEnd()) { ans[loc++] = (Element) ls.getItem(); ls.next(); } return ans; } public String toString() { return "Set " + ls; } }