Class Table


  • public class Table
    extends TableAbstract
    This class allows us to represent integer tables that are useful objects when defining extension constraints.
    • Constructor Detail

      • Table

        public Table()
    • 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 class TableAbstract
        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 class TableAbstract
        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 tuple
        otherVals - 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 r,
                             java.util.function.Function<Integer,​int[]> f)
      • intersectionWith

        public Table intersectionWith​(Table other)
      • 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)