Class Utils

java.lang.Object
org.jacop.jasat.utils.Utils

public final class Utils extends Object
Contains utils for arrays manipulation
Version:
4.9
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final Integer[]
    ensure(Integer[] array, int size)
     
    static final <E> Set<E>[]
    ensure(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 final int[][]
    resize(int[][] array, int newSize)
    resize for int[][]
    static final int[][]
    resize(int[][] array, int newSize, int size)
    the same, but with the number of elements to copy from old list
    static final int[]
    resize(int[] array, int newSize, int size, MemoryPool pool)
    Resize the array to newSize, using the given memory pool
    static final int[]
    resize(int[] array, int newSize, MemoryPool pool)
     
    static 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
  • Field Details

  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • 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 Integer[] ensure(Integer[] array, int size)
    • ensure

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

      public static 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