Class XVariables.XArray

  • Enclosing class:
    XVariables

    public static final class XVariables.XArray
    extends ParsingEntry.VEntry
    The class used to represent arrays of variables.
    • Field Detail

      • size

        public final int[] size
        The size of the array, as defined in XCSP3.
      • vars

        public final XVariables.XVar[] vars
        The flat (one-dimensional) array composed of all variables contained in the (multi-dimensional) array. This way, we can easily deal with arrays of any dimensions.
    • Constructor Detail

      • XArray

        public XArray​(String id,
                      Types.TypeVar type,
                      int[] size)
        Builds an array of variables with the specified id, type and size.
      • XArray

        public XArray​(String id,
                      Types.TypeVar type,
                      int[] sizes,
                      Domains.IDom dom)
        Builds an array of variables with the specified id, type and size. All variables are directly defined with the specified domain.
    • Method Detail

      • indexesFor

        protected int[] indexesFor​(int flatIndex)
        Transforms a flat index into a multi-dimensional index.
      • varAt

        public XVariables.XVar varAt​(int... indexes)
        Returns the variable at the position given by the multi-dimensional index.
      • domAt

        public Domains.Dom domAt​(int... indexes)
        Returns the domain of the variable at the position given by the multi-dimensional index. However, if this variable does not exist or if its degree is 0, null is returned.
      • buildIndexRanges

        public Values.IntegerEntity[] buildIndexRanges​(String compactForm)
        Builds an array of IntegerEnity objects for representing the ranges of indexes that are computed with respect to the specified compact form.
      • setDom

        public void setDom​(String s,
                           Domains.IDom dom)
        Any variable that matches one compact form present in the specified string is built with the specified domain.
      • getVarsFor

        public List<XVariables.XVar> getVarsFor​(String compactForm)
        Returns the list of variables that match the specified compact form. For example, for x[1..3], the list will contain x[1] x[2] and x[3].