<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">// File: SetTest.java

/**
 * This class is used for testing the implementation of the Element and Set
 * classes.
 */
public class SetTester {

    /**
     * This is a sample main function for testing the implementation of the
     * Element and Set classes.
     */
    public static void main(String[] args) {
        int N = 9;
        Element[] elements = new Element[N];

        /*
         * We build N singleton sets: {0},{1},...,{N-1} by constructing an array
         * of elements 0,1,..(N-1). Note that the construction of each element
         * in this array creates the singleton set that contains it.
         */
        for (int i = 0; i &lt; elements.length; i++) {
            elements[i] = new Element(new Integer(i));
        }

        // use the path compression heuristic
        Element.usePathCompression = true;

        // peform some set operations
        Set s1, s2;
        s1 = Set.union(elements[0].findSet(), elements[1].findSet());
        s2 = Set.union(elements[2].findSet(), elements[3].findSet());
        Set.union(s1, s2);
        s1 = Set.union(elements[4].findSet(), elements[5].findSet());
        s2 = Set.union(elements[6].findSet(), elements[7].findSet());
        Set.union(s2, s1);
        Set.union(elements[4].findSet(), elements[8].findSet());
        Set.union(elements[0].findSet(), elements[4].findSet());

        // print elements
        for (int i = 0; i &lt; elements.length; i++)
            System.out.println(elements[i]);
    }
}</pre></body></html>