Class PredefinedOrder

java.lang.Object
org.jacop.constraints.geost.PredefinedOrder
All Implemented Interfaces:
LexicographicalOrder

public class PredefinedOrder extends Object implements LexicographicalOrder
Version:
4.10

It provides a very simple lexicographical order based on the dimension ordering, with the possibility to choose the most significant dimension

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final int[]
    It stores the position of dimensions in the ordering starting from most significant dimension to the least significant one.
    (package private) final int[]
    It stores the initial position of dimensions in the ordering array.
    (package private) final int[]
    It stores the ordering of dimensions without taking most significant dimension into account.
    (package private) int
    It stores currently the most significant dimension.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PredefinedOrder(int[] ordering, int mostSignificantDimension)
    It specifies the comparison of k-dimensional point comparator based on the dimension ordering and the most significant dimension.
  • Method Summary

    Modifier and Type
    Method
    Description
    It checks the invariants for this order.
    int
    compare(int[] p1, int[] p2)
    It compares two k-dimensional points.
    int
    dimensionAt(int precedenceLevel)
    It provides the dimension corresponding to the given precedence level
    int
    This is equivalent to the call precedenceOf(0).
    int[]
    It returns the ordering of dimensions used when no shift is applied (i.e.
    int
    precedenceOf(int dimension)
    It provides the precedence level of the given dimension.
    private void
     
    void
    It shifts the lexicographical order so that the most significant dimension is set to d.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • mostSignificantDimension

      int mostSignificantDimension
      It stores currently the most significant dimension.
    • masterOrdering

      final int[] masterOrdering
      It stores the ordering of dimensions without taking most significant dimension into account.
    • dimensionPosition

      final int[] dimensionPosition
      It stores the initial position of dimensions in the ordering array. It does not reflect shift due to most significant dimension.
    • actualDimensionOrder

      final int[] actualDimensionOrder
      It stores the position of dimensions in the ordering starting from most significant dimension to the least significant one.
  • Constructor Details

    • PredefinedOrder

      public PredefinedOrder(int[] ordering, int mostSignificantDimension)
      It specifies the comparison of k-dimensional point comparator based on the dimension ordering and the most significant dimension.
      Parameters:
      ordering - how dimensions are stored within each compared point.
      mostSignificantDimension - the most significant dimension
  • Method Details

    • checkInvariants

      public String checkInvariants()
      It checks the invariants for this order.
      Returns:
      it returns string describing the violated invariant, or null if everything is in order.
    • recomputeActualDimensionOrder

      private void recomputeActualDimensionOrder()
    • compare

      public int compare(int[] p1, int[] p2)
      Description copied from interface: LexicographicalOrder
      It compares two k-dimensional points.
      Specified by:
      compare in interface LexicographicalOrder
      Parameters:
      p1 - point 1
      p2 - point 2
      Returns:
      comparison result: a negative value if p1 is smaller than p2, 0 if p1 is equal to p2, and a positive value if p1 is larger than p2.
    • dimensionAt

      public int dimensionAt(int precedenceLevel)
      Description copied from interface: LexicographicalOrder
      It provides the dimension corresponding to the given precedence level
      Specified by:
      dimensionAt in interface LexicographicalOrder
      Parameters:
      precedenceLevel - the given precedence level
      Returns:
      an integer value of the dimension.
    • precedenceOf

      public int precedenceOf(int dimension)
      Description copied from interface: LexicographicalOrder
      It provides the precedence level of the given dimension. 0 is the most significant.
      Specified by:
      precedenceOf in interface LexicographicalOrder
      Parameters:
      dimension - the given dimension
      Returns:
      integer value of the precedence level.
    • setMostSignificantDimension

      public void setMostSignificantDimension(int d)
      Description copied from interface: LexicographicalOrder
      It shifts the lexicographical order so that the most significant dimension is set to d.
      Specified by:
      setMostSignificantDimension in interface LexicographicalOrder
      Parameters:
      d - the dimension to be considered most significant
    • getMostSignificantDimension

      public int getMostSignificantDimension()
      Description copied from interface: LexicographicalOrder
      This is equivalent to the call precedenceOf(0).
      Specified by:
      getMostSignificantDimension in interface LexicographicalOrder
      Returns:
      the most significant dimension
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • masterOrdering

      public int[] masterOrdering()
      Description copied from interface: LexicographicalOrder
      It returns the ordering of dimensions used when no shift is applied (i.e. when the most significant dimension is not changed)
      Specified by:
      masterOrdering in interface LexicographicalOrder
      Returns:
      the ordering of dimensions without a shift.