src/main/java/org/thegalactic/util/ComparableSet.java
public int compareTo(final ComparableSet set) {

        int cmp;

        // case of equality between this component and object
        if (this.equals(set)) {
            cmp = 0;
        } else {
            // computes index i of the first element in set minus this
            // if i doesn't exist, then this component is not smaller than the set by lectic order
            final TreeSet<Comparable> setMinusThis = new TreeSet(set);
            setMinusThis.removeAll(this);
            if (setMinusThis.isEmpty()) {
                cmp = 1;
            } else {
                final Comparable i = setMinusThis.first();
                // compute this inter {1, ..., i-1}
                final TreeSet setAiMinus1 = new TreeSet();
                for (final Object c : this) {
                    if (i.compareTo(c) > 0) {
                        setAiMinus1.add(c);
                    }
                }
                // compute set inter {1, ..., i-1}
                final TreeSet setBiMinus1 = new TreeSet();
                for (final Object c : set) {
                    if (i.compareTo(c) > 0) {
                        setBiMinus1.add(c);
                    }
                }
                // if setAiminus1 and setBiminus1 are equal then this component is smaller than B by lectic order
                if (setAiMinus1.equals(setBiMinus1)) {
                    cmp = -1;
                } else {
                    cmp = 1;
                }
            }
        }
        return cmp;
    }
/**
     * Compares this component with those in parameter according to the lectic
     * order.
     *
     * The lectic order defines a sort on sets of elements extending the
     * inclusion order as follows:
     *
     * A set `A` is smaller than a set `B` iff there exists an element in `B\A`
     * such that any smaller element belonging to A also belongs to B. The
     * result is
     *
     * - zero if the identifiers are equal;
     * - 1 if this component's identifier is greater;
     * - -1 otherwise.
     *
     * This comparison method is needed to define a natural and total sort on a
     * sets.
     *
     * It allows to use sets of this class in a sorted collection
     *
     * @param set the specified element to be compared with this component
     *
     * @return a negative integer, zero, or a positive integer as this component
     *         is less than, equal to, or greater than the specified object according to
     *         the lectic order.
     *
     * @todo Is this correct? (see test)
     */
Compares this component with those in parameter according to the lectic
order.

The lectic order defines a sort on sets of elements extending the
inclusion order as follows.



- zero if the identifiers are equal;
- 1 if this component's identifier is greater;
- -1 otherwise.

This comparison method is needed to define a natural and total sort on a
sets.

It allows to use sets of this class in a sorted collection

@param set the specified element to be compared with this component

@return a negative integer, zero, or a positive integer as this component
is less than, equal to, or greater than the specified object according to
the lectic order.


Compares this component with those in parameter according to the lectic order . The lectic order defines a sort on sets of elements extending the inclusion order as follows . - zero if the identifiers are equal ; - 1 if this component ' s identifier is greater ; - - 1 otherwise . This comparison method is needed to define a natural and total sort on a sets . It allows to use sets of this class in a sorted collection @param set the specified element to be compared with this component @return a negative integer zero or a positive integer as this component is less than equal to or greater than the specified object according to the lectic order .
public int compareTo(final ComparableSet set) {
        int cmp;
        if (this.equals(set)) {
            cmp = 0;
        } else {
            final TreeSet<Comparable> setMinusThis = new TreeSet(set);
            setMinusThis.removeAll(this);
            if (setMinusThis.isEmpty()) {
                cmp = 1;
            } else {
                final Comparable i = setMinusThis.first();
                final TreeSet setAiMinus1 = new TreeSet();
                for (final Object c : this) {
                    if (i.compareTo(c) > 0) {
                        setAiMinus1.add(c);
                    }
                }
                final TreeSet setBiMinus1 = new TreeSet();
                for (final Object c : set) {
                    if (i.compareTo(c) > 0) {
                        setBiMinus1.add(c);
                    }
                }
                if (setAiMinus1.equals(setBiMinus1)) {
                    cmp = -1;
                } else {
                    cmp = 1;
                }
            }
        }
        return cmp;
    }
public int compareTo ( final ComparableSet set ) { int cmp ; if ( this . equals ( set ) ) { cmp = 0 ; } else { final TreeSet < Comparable > setMinusThis = new TreeSet ( set ) ; setMinusThis . removeAll ( this ) ; if ( setMinusThis . isEmpty ( ) ) { cmp = 1 ; } else { final Comparable i = setMinusThis . first ( ) ; final TreeSet setAiMinus1 = new TreeSet ( ) ; for ( final Object c : this ) { if ( i . compareTo ( c ) > 0 ) { setAiMinus1 . add ( c ) ; } } final TreeSet setBiMinus1 = new TreeSet ( ) ; for ( final Object c : set ) { if ( i . compareTo ( c ) > 0 ) { setBiMinus1 . add ( c ) ; } } if ( setAiMinus1 . equals ( setBiMinus1 ) ) { cmp = - 1 ; } else { cmp = 1 ; } } } return cmp ; }
Compares this component with those in parameter according to the lectic
 order.
Compares this component with those in parameter according to the lectic order .
// case of equality between this component and object // computes index i of the first element in set minus this // if i doesn't exist, then this component is not smaller than the set by lectic order // compute this inter {1, ..., i-1} // compute set inter {1, ..., i-1} // if setAiminus1 and setBiminus1 are equal then this component is smaller than B by lectic order