Package edu.uky.ai.csp.kr

# Class Domain

java.lang.Object
edu.uky.ai.csp.kr.Domain

All Implemented Interfaces:
  `java.lang.Cloneable`, `java.lang.Iterable<java.lang.Object>`

    public class Domain
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.Object>, java.lang.Cloneable

A domain is the set of values that a variable might possibly be assigned.

Author:
  Stephen G. Ware

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `Variable` | `variable` | The variable in question

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `Domain​(Variable variable, java.lang.Object[] values)` | Constructs a new domain object with a given set of possible values.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `add​(java.lang.Object value)` | Adds a potential value to the domain.
  `Domain` | `clone()` |
  `boolean` | `contains​(java.lang.Object value)` | Checks if a given value is one of the possible values this variable might be assigned.
  `java.lang.Object` | `getValue()` | If this domain has only 1 possible value, this method returns it.
  `java.util.Iterator<java.lang.Object>` | `iterator()` |
  `void` | `remove​(java.lang.Object value)` | Removes a potential value from the domain.
  `void` | `set​(java.lang.Object value)` | Removes all values except for a given value from the domain.
  `int` | `size()` | Returns the number of possible values this variable might be assigned.
  `java.lang.String` | `toString()` |

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Field Details

  - ### variable

    public final Variable variable
    The variable in question

- ## Constructor Details

  - ### Domain

    public Domain​(Variable variable, java.lang.Object[] values)
    Constructs a new domain object with a given set of possible values.
    Parameters:
      `variable` - the variable to be assigned a value
      `values` - a set of possible values that variable might be assigned

- ## Method Details

  - ### toString

    public java.lang.String toString()
    Overrides:
      `toString` in class `java.lang.Object`

  - ### iterator

    public java.util.Iterator<java.lang.Object> iterator()
    Specified by:
      `iterator` in interface `java.lang.Iterable<java.lang.Object>`

  - ### clone

    public Domain clone()
    Overrides:
      `clone` in class `java.lang.Object`

  - ### size

    public int size()
    Returns the number of possible values this variable might be assigned.
    Returns:
      the number of values

  - ### contains

    public boolean contains​(java.lang.Object value)
    Checks if a given value is one of the possible values this variable might be assigned.
    Parameters:
      `value` - the value to test
    Returns:
      true if this domain contains the given value, false otherwise

  - ### getValue

    public java.lang.Object getValue()
    If this domain has only 1 possible value, this method returns it.
    Returns:
      the value assigned to the variable
    Throws:
      `java.lang.IllegalStateException` - if the domain has 0 or more than 1 possible value

  - ### add

    public void add​(java.lang.Object value)
    Adds a potential value to the domain.
    Parameters:
      `value` - the value to add to the set of possible values

  - ### remove

    public void remove​(java.lang.Object value)
    Removes a potential value from the domain.
    Parameters:
      `value` - the value to remove from the set of possible values

  - ### set

    public void set​(java.lang.Object value)
    Removes all values except for a given value from the domain. This effectively sets the variable's value to the given value.
    Parameters:
      `value` - the value to be retained