view src/main/java/fj/Ordering.java @ 0:fe80c1edf1be

add getLoop
author tatsuki
date Fri, 20 Mar 2015 21:04:03 +0900
parents
children
line wrap: on
line source

package fj;

/**
 * The comparison of two instances of a type may have one of three orderings; less than, equal or
 * greater than.
 *
 * @version %build.number%
 */
public enum Ordering {
  /**
   * Less than.
   */
  LT,

  /**
   * Equal.
   */
  EQ,

  /**
   * Greater than.
   */
  GT;

  public int toInt() { return ordinal() - 1 ; }
  public static Ordering fromInt(int cmp) {
    return cmp == 0 ? EQ : cmp > 0 ? GT : LT;
  }
}