package edu.vt.marian.common;

import java.util.*;
import java.io.*;

import edu.vt.marian.common.*;

/**
 * A quicksort object which can be used to sort the elements of
 * an enumeration in either non-increasing or non-decreasing order.
 * The only requirement is that each element of the object being
 * sorted implements the Sortable interface.  Basically, this means
 * an object provides a compare() method which can be used to
 * determine whether one object is less than, equal to, or greater
 * than another object.
 *
 * @author Paul Mather
 * @version 0.9
 */
public interface Sortable
{
    /** Indicate that we want to sort in non-decreasing order */
    public final static int INCREASING = 1;

    /** Indicate that we want to sort in non-increasig order */
    public final static int DECREASING = 2;

    /**
     * Magic number to indicate object being compared against us is
     * less than our value
     */
    public final static int LESS = -1;

    /**
     * Magic number to indicate object being compared against us is
     * equal to our value
     */
    public final static int EQUAL = 0;

    /**
     * Magic number to indicate object being compared against us is
     * greater than our value
     */
    public final static int GREATER = 1;

    /**
     * Magic number to indicate object being compared against us is
     * incomparable to us.
     */
    public final static int INCOMPARABLE = 23;

    /**
     * Compare an object with ourselves and return an int indicating
     * how it compares relative to us.  The int is returned as follows:
     * <UL>
     * <LI>Sortable.LESS if our value is less than that of the object
     * to which we are being compared;
     * <LI>Sortable.EQUAL if our value is equal to that of the object
     * to which we are being compared;
     * <LI>Sortable.GREATER if our value is greater than that of the object
     * to which we are being compared;
     * <LI>Sortable.INCOMPARABLE if our value cannot be validly compared
     * against the object given (e.g., it is of a different type, with
     * no meaningful comparison semantics relative to us)
     * @param obj the object to which we are being compared
     * @return an integer denoting how we compare to the obj supplied
     */
    public int compare(Object obj);
}
