Class Utils


  • public final class Utils
    extends java.lang.Object
    Contains utils for arrays manipulation
    Version:
    4.8
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int MASK  
    • Constructor Summary

      Constructors 
      Constructor Description
      Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Integer[] ensure​(java.lang.Integer[] array, int size)  
      static <E> java.util.Set<E>[] ensure​(java.util.HashSet<E>[] array, int size)  
      static int not​(int i)
      given a positive var, returns the literal that represents the negation of the variable variable -> literal
      static int[][] resize​(int[][] array, int newSize)
      resize for int[][]
      static int[][] resize​(int[][] array, int newSize, int size)
      the same, but with the number of elements to copy from old list
      static int[] resize​(int[] array, int newSize, int size, MemoryPool pool)
      Resize the array to newSize, using the given memory pool
      static int[] resize​(int[] array, int newSize, MemoryPool pool)  
      static java.lang.String showClause​(int[] clause)
      facility to print a clause to a string
      static int var​(int i)
      get the "absolute value" of the int (the variable that corresponds to the literal) literal -> variable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • resize

        public static final int[] resize​(int[] array,
                                         int newSize,
                                         int size,
                                         MemoryPool pool)
        Resize the array to newSize, using the given memory pool
        Parameters:
        array - the array to resize
        newSize - the size of the new array
        size - the number of elements to copy from @param array
        pool - the MemoryPool from which to find an int[]
        Returns:
        a new int[] with required size, and elements from @param array
      • resize

        public static final int[] resize​(int[] array,
                                         int newSize,
                                         MemoryPool pool)
      • resize

        public static final int[][] resize​(int[][] array,
                                           int newSize)
        resize for int[][]
        Parameters:
        array - the array to resize
        newSize - the size of the array we want
        Returns:
        a new array which first elements are the same as the ones in array
      • resize

        public static final int[][] resize​(int[][] array,
                                           int newSize,
                                           int size)
        the same, but with the number of elements to copy from old list
        Parameters:
        array - array to be extended
        newSize - new size for the array
        size - the number of elements to copy from the old
        Returns:
        a new array which first elements are the same as the ones in array
      • ensure

        public static final java.lang.Integer[] ensure​(java.lang.Integer[] array,
                                                       int size)
      • ensure

        public static final <E> java.util.Set<E>[] ensure​(java.util.HashSet<E>[] array,
                                                          int size)
      • showClause

        public static java.lang.String showClause​(int[] clause)
        facility to print a clause to a string
        Parameters:
        clause - the clause to print
        Returns:
        a nice representation of the clause
      • var

        public static int var​(int i)
        get the "absolute value" of the int (the variable that corresponds to the literal) literal -> variable
        Parameters:
        i - the literal
        Returns:
        the variable
      • not

        public static int not​(int i)
        given a positive var, returns the literal that represents the negation of the variable variable -> literal
        Parameters:
        i - the variable
        Returns:
        the negated variable