Package org.xcsp.parser.entries
Class XVariables.XArray
- java.lang.Object
-
- org.xcsp.parser.entries.ParsingEntry
-
- org.xcsp.parser.entries.ParsingEntry.VEntry
-
- org.xcsp.parser.entries.XVariables.XArray
-
- Enclosing class:
- XVariables
public static final class XVariables.XArray extends ParsingEntry.VEntry
The class used to represent arrays of variables.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.xcsp.parser.entries.ParsingEntry
ParsingEntry.CEntry, ParsingEntry.OEntry, ParsingEntry.VEntry
-
-
Field Summary
Fields Modifier and Type Field Description int[]
size
The size of the array, as defined in XCSP3.XVariables.XVar[]
vars
The flat (one-dimensional) array composed of all variables contained in the (multi-dimensional) array.-
Fields inherited from class org.xcsp.parser.entries.ParsingEntry.VEntry
type
-
Fields inherited from class org.xcsp.parser.entries.ParsingEntry
attributes, classes, flags, id, note
-
-
Constructor Summary
Constructors Constructor Description XArray(String id, Types.TypeVar type, int[] size)
Builds an array of variables with the specified id, type and size.XArray(String id, Types.TypeVar type, int[] sizes, Domains.IDom dom)
Builds an array of variables with the specified id, type and size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.Domains.Dom
domAt(int... indexes)
Returns the domain of the variable at the position given by the multi-dimensional index.List<XVariables.XVar>
getVarsFor(String compactForm)
Returns the list of variables that match the specified compact form.protected int[]
indexesFor(int flatIndex)
Transforms a flat index into a multi-dimensional index.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.String
toString()
XVariables.XVar
varAt(int... indexes)
Returns the variable at the position given by the multi-dimensional index.-
Methods inherited from class org.xcsp.parser.entries.ParsingEntry.VEntry
getType
-
Methods inherited from class org.xcsp.parser.entries.ParsingEntry
copyAttributesOf, getAttributeValue, getAttributeValue, getAttributeValue
-
-
-
-
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].
-
toString
public String toString()
- Overrides:
toString
in classParsingEntry.VEntry
-
-