Package org.xcsp.common.structures
Class Table
- java.lang.Object
-
- org.xcsp.common.structures.TableAbstract
-
- org.xcsp.common.structures.Table
-
public class Table extends TableAbstract
This class allows us to represent integer tables that are useful objects when definingextension
constraints.
-
-
Field Summary
-
Fields inherited from class org.xcsp.common.structures.TableAbstract
positive, TABLE_SYNTAX_PB
-
-
Constructor Summary
Constructors Constructor Description Table()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Table
add(int[]... tuples)
Adds the specified integer tuples to the table.Table
add(int val, int... otherVals)
Adds an integer tuple to the table.Table
add(String s)
Adds the tuples obtained after parsing the specified string.Table
add(Collection<int[]> tuples)
Adds all tuples of the specified collection to the table.Table
add(java.util.stream.Stream<int[]> stream)
Adds all tuples of the specified stream to the table.Table
add(Table table)
Adds all tuples of the specified table to this table.Table
addColumnWithValue(int position, int value)
Table
addFrom(Range.Rangesx2 r2, java.util.function.BiFunction<Integer,Integer,int[]> f)
Table
addFrom(Range r, java.util.function.Function<Integer,int[]> f)
static int[][]
clean(int[]... tuples)
Returns an array of tuples in lexicographic order, and without any duplicates.static int[][]
clean(List<int[]> tuples)
Returns an array of tuples in lexicographic order, and without any duplicates.Table
intersectionWith(Table other)
Table
positive(Boolean positive)
Sets if the table is positive (i.e, contains supports) or negative (i.e., contains conflicts)int
size()
Returns the number of tuples in this tableint[][]
toArray()
Returns a 2-dimensional array corresponding to the collected tuples.static int[][]
toOrdinaryTable(int[][] shortTable, int... nValues)
static int[][]
toOrdinaryTable(int[][] shortTable, int[][] values)
int[][]
toOrdinaryTableArray(int... nValues)
int[][]
toOrdinaryTableArray(int[][] values)
String
toString()
-
Methods inherited from class org.xcsp.common.structures.TableAbstract
controlStringRepresentationOfTuples
-
-
-
-
Method Detail
-
clean
public static int[][] clean(int[]... tuples)
Returns an array of tuples in lexicographic order, and without any duplicates.- Parameters:
tuples
- an array of tuples- Returns:
- an array of tuples in lexicographic order, and without any duplicates
-
clean
public static int[][] clean(List<int[]> tuples)
Returns an array of tuples in lexicographic order, and without any duplicates.- Parameters:
tuples
- a list of tuples- Returns:
- an array of tuples in lexicographic order, and without any duplicates
-
toOrdinaryTable
public static int[][] toOrdinaryTable(int[][] shortTable, int[][] values)
-
toOrdinaryTable
public static int[][] toOrdinaryTable(int[][] shortTable, int... nValues)
-
positive
public Table positive(Boolean positive)
Description copied from class:TableAbstract
Sets if the table is positive (i.e, contains supports) or negative (i.e., contains conflicts)- Overrides:
positive
in classTableAbstract
- Parameters:
positive
- a Boolean value indicating if the table is positive (true
) or negative (false
)- Returns:
- this table
-
size
public int size()
Description copied from class:TableAbstract
Returns the number of tuples in this table- Specified by:
size
in classTableAbstract
- Returns:
- the number of tuples in this table
-
add
public Table add(int val, int... otherVals)
Adds an integer tuple to the table.- Parameters:
val
- the first integer of the specified tupleotherVals
- the orther integers of the specified tuple- Returns:
- this integer table
-
add
public Table add(int[]... tuples)
Adds the specified integer tuples to the table.- Parameters:
tuples
- a sequence of other tuples- Returns:
- this integer table
-
add
public Table add(java.util.stream.Stream<int[]> stream)
Adds all tuples of the specified stream to the table.- Parameters:
stream
- a stream of tuples to be added to the table- Returns:
- this integer table
-
add
public Table add(Collection<int[]> tuples)
Adds all tuples of the specified collection to the table.- Parameters:
tuples
- a collection of tuples to be added to the table- Returns:
- this integer table
-
add
public Table add(Table table)
Adds all tuples of the specified table to this table.- Parameters:
table
- another table- Returns:
- this integer table
-
add
public Table add(String s)
Adds the tuples obtained after parsing the specified string. The string must represent a sequence of tuples as defined in XCSP3. For example, it could be"(0,0,1)(0,2,0)(1,0,1)(1,1,2)"
.- Parameters:
s
- a string representing a sequence of integer tuples- Returns:
- this integer table
-
addFrom
public Table addFrom(Range.Rangesx2 r2, java.util.function.BiFunction<Integer,Integer,int[]> f)
-
addColumnWithValue
public Table addColumnWithValue(int position, int value)
-
toArray
public int[][] toArray()
Returns a 2-dimensional array corresponding to the collected tuples. Tuples are sorted and made distinct.- Returns:
- a 2-dimensional array corresponding to the collected tuples
-
toOrdinaryTableArray
public int[][] toOrdinaryTableArray(int[][] values)
-
toOrdinaryTableArray
public int[][] toOrdinaryTableArray(int... nValues)
-
-