package rpi.goldsd.container;

/**
 * The <tt>Comparable</tt> interface defines the methods required by any
 * object that can be compared to other objects of the same type.
 * Many other classes defined in this package maintain sets of
 * <tt>Comparable</tt> (and <tt>Hashable</tt>) objects such that
 * sorting, searching, and other order-dependent operations may be
 * performed in a generic manner.
 * <p>
 * Classes implementing the <tt>Comparable</tt> interface should provide
 * a <i>strict total ordering</i> of elements.  In other words, every
 * pair of elements must be related by the <tt>&gt;</tt> and
 * <tt>==</tt> operators in in the following manner
 * (from David Musser's <b>STL Tutorial and Reference Guide</b>):
 * <ul>
 * <li> <b>Transitivity</b>: for every <i>x</i>, <i>y</i>, <i>z</i>
 *      in <i>S</i>, if <i>x R y</i> and <i>y R z</i>, then
 *      <i>x R z</i>.
 * <li> <b>Trichotomy</b>: for every <i>x</i> and <i>y</i> in
 *      <i>S</i>, exactly one of the following is true: <i>x R y</i>,
 *      <i>y R x</i>, or <i>x == y</i>.
 * </ul>
 * Note that the <tt>==</tt> operator implicitly adheres to the
 * given Trichotomy rule.
 *
 * @see AssociativeContainer
 * @see ListNode
 * @version 1.0, 3/15/98
 * @author David Goldschmidt
 */
public interface Comparable
{
  /**
   * Returns <tt>true</tt> if the implicit <tt>Comparable</tt> object is
   * equal to the given <tt>Comparable</tt> object <tt>C</tt>.  Essentially,
   * this method is used to define the equivalence relation on the
   * given type implementing the <tt>Comparable</tt> interface.
   * @param C the explicit <tt>Comparable</tt> object to be compared.
   * @return <tt>true</tt> if the implicit <tt>Comparable</tt> object is
   *         equal to the given <tt>Comparable</tt> object <tt>C</tt>;
   *         <tt>false</tt> otherwise.
   */
  public boolean isEqualTo( Comparable C );


  /**
   * Returns <tt>true</tt> if the implicit <tt>Comparable</tt> object is
   * less than the given <tt>Comparable</tt> object <tt>C</tt>.
   * @param C the explicit <tt>Comparable</tt> object to be compared.
   * @return <tt>true</tt> if the implicit <tt>Comparable</tt> object is
   *         less than the given <tt>Comparable</tt> object <tt>C</tt>;
   *         <tt>false</tt> otherwise.
   */
  public boolean isLessThan( Comparable C );
}

