Class Domain

java.lang.Object
org.graph4j.util.Domain

public class Domain extends Object
A domain of available non-negative values for a vertex. The values of the domain are indexed, being represented internally using an array.
Author:
Cristian Frăsinaru
  • Constructor Details

    • Domain

      public Domain(Domain parent)
      Used for inheriting in a lazy fashion another domain's values.
      Parameters:
      parent - the parent domain.
    • Domain

      public Domain(int vertex, int value)
      Used for creating single-value domains.
      Parameters:
      vertex - a vertex number.
      value - the value assigned for the vertex.
    • Domain

      public Domain(int vertex, int[] values)
      Parameters:
      vertex - a vertex number.
      values - an array of available values for the vertex.
  • Method Details

    • vertex

      public int vertex()
      Returns:
      the vertex number.
    • size

      public int size()
      Returns:
      the number of values in the domain.
    • values

      public int[] values()
      Returns:
      the values in the domain.
    • valueAt

      public int valueAt(int pos)
      Parameters:
      pos - a position in the domain.
      Returns:
      the value at the specified position.
    • poll

      public int poll()
      Returns:
      removes and returns a value in the domain.
    • remove

      public boolean remove(int value)
      Parameters:
      value - the value to be removed from the domain.
      Returns:
      true if the domain has changed as a result of this operation.
    • indexOf

      public int indexOf(int value)
      Parameters:
      value - a value;
      Returns:
      the position (index) of the value in the domain.
    • contains

      public boolean contains(int value)
      Parameters:
      value - a value.
      Returns:
      true if the value belongs to the domain.
    • removeAtPos

      public void removeAtPos(int pos)
      Removes the value at the specified position.
      Parameters:
      pos - a position.
    • swapPos

      public void swapPos(int i, int j)
      Swaps the values at the specified positions.
      Parameters:
      i - a position in the domain.
      j - a position in the domain.
    • toString

      public String toString()
      Overrides:
      toString in class Object