Blame | Last modification | View Log | RSS feed
// Written by Ira Snyder// 11-03-2004import java.io.*;import java.util.*;class UnorderedTree {private Object root;private Set subtrees;private int size;public UnorderedTree( ) { } //constructs an empty treepublic UnorderedTree( Object root ) { //constructs a singletonthis.root = root;subtrees = new HashSet(); //empty setsize = 1;}//constructor to create any tree that is not a singleton//and is not an empty treepublic UnorderedTree( Object root, Set trees ) {this(root);for( Iterator it=trees.iterator(); it.hasNext(); ) {Object object = it.next();if( object instanceof UnorderedTree ) {UnorderedTree tree = (UnorderedTree)object;subtrees.add(tree);size += tree.size;}}}public int size( ) { return size; }} //end class UnorderedTree