Cream version 1.06 Core API Specification

jp.ac.kobe_u.cs.cream
Class IntDomain

java.lang.Object
  extended by jp.ac.kobe_u.cs.cream.Domain
      extended by jp.ac.kobe_u.cs.cream.IntDomain
All Implemented Interfaces:
Cloneable

public class IntDomain
extends Domain

IntDomain class represents domains on integers. Integer domain is implemented as a list of intervals.

Since:
1.0
See Also:
IntVariable

Field Summary
static IntDomain EMPTY
          Empty integer domain
static IntDomain FULL
          Full integer domain MIN_VALUE..MAX_VALUE.
static int MAX_VALUE
          Maximum integer value (231-1)
static int MIN_VALUE
          Minimum integer value (-231+1)
 
Constructor Summary
IntDomain()
          Constructs the empty integer domain.
IntDomain(int value)
          Constructs a singleton integer domain.
IntDomain(int min, int max)
          Constructs an integer domain of min..max.
 
Method Summary
 Domain cap(Domain d)
          Returns a new domain of the intersection (optional operation).
 IntDomain capInterval(int lo, int hi)
          Returns a new domain which is the intersection of the curren domain and the interval lo..hi.
 Object clone()
          Returns true when the domain is empty.
 boolean contains(int elem)
          Returns true when the domain containts elem value.
 boolean contains(Object o)
          Returns true when the domain contains the element o.
 Domain cup(Domain d)
          Not implemented.
 IntDomain delete(int elem)
          Returns a new domain obtained by deleting elem value.
 IntDomain delete(int lo, int hi)
          Returns a new domain obtained by deleting the interval lo..hi.
 Domain delete(Object o)
          Returns a new domain obtained by deleting the element o (optional operation).
 Domain difference(Domain d)
          Not implemented.
 Object element()
          Returns the only element when the domain is a singleton.
 Iterator<Domain> elements()
          Returns the iterator of domain elements.
 boolean equals(Domain d0)
          Returns true when the domain is equal to another domain d.
 Domain insert(Object o)
          Not implemented.
 int max()
          Returns the current maximum value of the domain.
 int min()
          Returns the current minimum value of the domain.
 int randomElement()
          Returns a randomly selected element value.
 void remove(int elem)
          Removes elem from the domain.
 void remove(Object o)
          Removes o from the domain.
 String toString()
           
 int value()
          Returns the current only value when the domain is a singleton.
 
Methods inherited from class jp.ac.kobe_u.cs.cream.Domain
isEmpty, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final int MIN_VALUE
Minimum integer value (-231+1)

See Also:
Constant Field Values

MAX_VALUE

public static final int MAX_VALUE
Maximum integer value (231-1)

See Also:
Constant Field Values

EMPTY

public static IntDomain EMPTY
Empty integer domain


FULL

public static IntDomain FULL
Full integer domain MIN_VALUE..MAX_VALUE.

Constructor Detail

IntDomain

public IntDomain()
Constructs the empty integer domain.


IntDomain

public IntDomain(int value)
Constructs a singleton integer domain.

Parameters:
value - the singleton value

IntDomain

public IntDomain(int min,
                 int max)
Constructs an integer domain of min..max.

Parameters:
min - the lower bound
max - the upper bound
Method Detail

equals

public boolean equals(Domain d0)
Description copied from class: Domain
Returns true when the domain is equal to another domain d.

Specified by:
equals in class Domain
Parameters:
d0 - another domain
Returns:
true when the domain is equal to d

clone

public Object clone()
Description copied from class: Domain
Returns true when the domain is empty.

Specified by:
clone in class Domain
Returns:
true when the domain is empty

elements

public Iterator<Domain> elements()
Description copied from class: Domain
Returns the iterator of domain elements.

Specified by:
elements in class Domain
Returns:
the iterator of domain elements

min

public int min()
        throws NoSuchElementException
Returns the current minimum value of the domain.

Returns:
the minimum value
Throws:
NoSuchElementException

max

public int max()
        throws NoSuchElementException
Returns the current maximum value of the domain.

Returns:
the maximum value
Throws:
NoSuchElementException

value

public int value()
          throws NoSuchElementException
Returns the current only value when the domain is a singleton.

Returns:
the singleton value
Throws:
NoSuchElementException

element

public Object element()
               throws NoSuchElementException
Description copied from class: Domain
Returns the only element when the domain is a singleton.

Specified by:
element in class Domain
Returns:
the only element
Throws:
NoSuchElementException

contains

public boolean contains(int elem)
Returns true when the domain containts elem value.

Parameters:
elem - the integer value to be checked
Returns:
true when the domain containts elem

contains

public boolean contains(Object o)
Description copied from class: Domain
Returns true when the domain contains the element o.

Specified by:
contains in class Domain
Parameters:
o - the element to be checked
Returns:
true when the domain contains o

randomElement

public int randomElement()
Returns a randomly selected element value.

Returns:
a randomly selected element value

insert

public Domain insert(Object o)
Not implemented.

Specified by:
insert in class Domain
Parameters:
o -
Returns:
the new domain

remove

public void remove(int elem)
Removes elem from the domain. This is an internal method.

Parameters:
elem - the integer value to be removed

remove

public void remove(Object o)
Removes o from the domain. This is an internal method.

Parameters:
o - the object to be removed

delete

public IntDomain delete(int elem)
Returns a new domain obtained by deleting elem value.

Parameters:
elem - the integer value to be deleted
Returns:
the new domain

delete

public Domain delete(Object o)
Description copied from class: Domain
Returns a new domain obtained by deleting the element o (optional operation).

Specified by:
delete in class Domain
Parameters:
o - an element to be deleted
Returns:
the new domain

delete

public IntDomain delete(int lo,
                        int hi)
Returns a new domain obtained by deleting the interval lo..hi.

Parameters:
lo - the lower bound of the interval to be deleted
hi - the upper bound of the interval to be deleted
Returns:
the new domain

cap

public Domain cap(Domain d)
Description copied from class: Domain
Returns a new domain of the intersection (optional operation).

Specified by:
cap in class Domain
Parameters:
d - another domain
Returns:
the intersection

cup

public Domain cup(Domain d)
Not implemented.

Specified by:
cup in class Domain
Parameters:
d -
Returns:
the union

difference

public Domain difference(Domain d)
Not implemented.

Specified by:
difference in class Domain
Parameters:
d -
Returns:
the difference

capInterval

public IntDomain capInterval(int lo,
                             int hi)
Returns a new domain which is the intersection of the curren domain and the interval lo..hi.

Parameters:
lo - the lower bound
hi - the upper bound
Returns:
the new domain

toString

public String toString()
Overrides:
toString in class Object

Cream version 1.06 Core API Specification

Cream: Constraint Programming Class Library for Java