<< Prev | - Up - | Next >> |

`OZ_FiniteDomain`

Instances of this class represent the domains for finite domain integer variables. A domain may have holes and can range from 0 to `OZ_getFDSup()`

, which is currently .

The representation of a finite domain consists of two parts. As long as there are no holes in the domain it suffices to store the lower and upper bound of the domain. Holes are stored in the so-called extension of the domain representation. This extension is either a bit-vector or a list of intervals. The kind of extension used is automatically determined and not visible outside.

The smallest element of a domain is denoted by and the largest element by .

`OZ_FDState`

[*enumerable type*]`enum OZ_FDState {fd_empty, fd_full, fd_bool, fd_singl};`

Values of this enumerable type are used when constructing an instance of the class

`OZ_FiniteDomain`

or in conjunction with operators`==`

resp.`!=`

.value

explanation

`fd_empty`

The domain does not contain any element.

`fd_full`

The domain contains all elements possible,

i. e. `fd_bool`

The domain contains 0 and 1.

`fd_singl`

The domain contains a single element.

`OZ_FiniteDomain`

[*default constructor*]`OZ_FiniteDomain(void);`

This default constructor creates an

*uninitialized*instance.`OZ_FiniteDomain`

[*constructor*]`OZ_FiniteDomain(const OZ_FiniteDomain &d);`

This copy constructor copies the current domain of

`d`

to`*this`

, so that`d`

and`*this`

denote the same domain but are independent representations of it.`OZ_FiniteDomain`

[*overloaded constructor*]`OZ_FiniteDomain(OZ_FDState state);`

This constructor creates an object which represents a domain according to the value of

`state`

. Valid values for`state`

are`fd_empty`

and`fd_full`

.`OZ_FiniteDomain`

[*overloaded constructor*]`OZ_FiniteDomain(OZ_Term t);`

This constructor is the composition of the default constructor and the member function

`initDescr()`

.`OZ_FiniteDomain`

[*overloaded constructor*]`OZ_FiniteDomain(const OZ_FSetValue &fs);`

This constructor initialises

`*this`

with the values contained in the finite set`fs`

.

The return value of all initialisation member functions is the size of the domain they initialised.

`initRange`

[*member function*]`int OZ_FiniteDomain::initRange(int l, int u);`

Initialises an instance of class

`OZ_FiniteDomain`

to the domain .In case

`l`

>`u`

, the domain is set to be empty.`initSingleton`

[*member function*]`int OZ_FiniteDomain::initSingleton(int l);`

Initialises an instance of class

`OZ_FiniteDomain`

to the domain .`initDescr`

[*member function*]`int OZ_FiniteDomain::initDescr(OZ_Term d);`

Initialises an instance of class

`OZ_FiniteDomain`

to a domain according to the domain description`d`

. The domain description must be conform with*level4*(see syntax definition of a domain description in Section 1.2.4, entry`expectDomDesc`

).`initFull`

[*member function*]`int OZ_FiniteDomain::initFull(void);`

Initialises an instance of class

`OZ_FiniteDomain`

to the domain .`initEmpty`

[*member function*]`int OZ_FiniteDomain::initEmpty(void);`

Initialises an instance of class

`OZ_FiniteDomain`

to the empty domain.`initBool`

[*member function*]`int OZ_FiniteDomain::initBool(void);`

Initialises an instance of class

`OZ_FiniteDomain`

to the domain .

`getMidElem`

[*constant member function*]`int getMidElem(void) const;`

This member function returns the element in the middle of the domain. For the domain it is . If this value happens to be a hole the element closest to it will be returned. In case there are two elements with the same distance to the middle of the domain the smaller one will be taken.

`getNextSmallerElem`

[*constant member function*]`int getNextSmallerElem(int v) const;`

This member function returns the largest element in the domain smaller than

`v`

. In case`v`

is the smallest element it returns -1.`getNextLargerElem`

[*constant member function*]`int getNextLargerElem(int v) const;`

This member function returns the smallest element in the domain larger than

`v`

. In case`v`

is the largest element it returns -1.`getLowerIntervalBd`

[*constant member function*]`int getLowerIntervalBd(int v) const;`

This member function returns the smallest value of the interval

`v`

belongs to. In case`v`

does not belong to any interval the function returns -1.`getUpperIntervalBd`

[*constant member function*]`int getUpperIntervalBd(int v) const;`

This member function returns the largest value of the interval

`v`

belongs to. In case`v`

does not belong to any interval the function returns -1.`getSize`

[*constant member function*]`int getSize(void) const;`

This member function returns the size of the domain, i. e. the number of elements in the domain.

`getMinElem`

[*constant member function*]`int getMinElem(void) const;`

This member function returns the smallest element of the domain.

`getMaxElem`

[*constant member function*]`int getMaxElem(void) const;`

This member function returns the largest element of the domain.

`getSingleElem`

[*constant member function*]`int getSingleElem(void) const;`

This member function returns the element of a singleton domain. In case the domain is not a singleton domain it returns -1.

`operator =`

[*operator member function*]`const OZ_FiniteDomain &operator = (const OZ_FiniteDomain &fd);`

This assignment operator copies

`fd`

to its left hand side, so that both domains are the same but are independent of each other.`operator ==`

[*operator constant member function*]`OZ_Boolean operator == (const OZ_FDState s) const;`

This operator returns

`OZ_TRUE`

if the domain corresponds to the value of`s`

. Otherwise it returns`OZ_FALSE`

.`operator ==`

[*operator constant member function*]`OZ_Boolean operator == (const int i) const;`

This operator returns

`OZ_TRUE`

if the domain contains only`i`

. Otherwise it returns`OZ_FALSE`

.`operator !=`

[*operator constant member function*]`OZ_Boolean operator != (const OZ_FDState s) const;`

This operator returns

`OZ_TRUE`

if the domain does*not*correspond to the value of`s`

. Otherwise it returns`OZ_FALSE`

.`operator !=`

[*operator constant member function*]`OZ_Boolean operator != (const int i) const;`

This operator returns

`OZ_TRUE`

if the domain does*not*contain`i`

or contains more than one element. Otherwise it returns`OZ_FALSE`

.`operator &`

[*operator constant member function*]`OZ_FiniteDomain operator & (const OZ_FiniteDomain &y) const;`

This member function returns the intersection of the finite domains represented by

`y`

and`*this`

.`operator |`

[*operator constant member function*]`OZ_FiniteDomain operator | (const OZ_FiniteDomain &y) const;`

This member function returns the union of the finite domains represented by

`y`

and`*this`

.`operator ~`

[*operator constant member function*]`OZ_FiniteDomain operator ~ (void) const;`

This member function returns the negation of the finite domain represented by

`*this`

. The negation is computed by removing all elements in`*this`

from .`operator &=`

[*operator member function*]`int operator &= (const OZ_FiniteDomain &y);`

int operator &= (const int y);This member function computes the intersection of the finite domains represented by

`y`

and`*this`

and assigns the result to`*this`

. Further, the size of the updated domain is returned.`operator +=`

[*operator member function*]`int operator += (const int y);`

This member function adds the element

`y`

to the domain represented by`*this`

and returns the size of the updated domain.`operator -=`

[*operator member function*]`int operator -= (const int y);`

This member function removes the element

`y`

from the domain represented by`*this`

and returns the size of the updated domain.`operator -=`

[*operator member function*]`int operator -= (const OZ_FiniteDomain &y);`

This member function removes all elements contained in the domain represented by

`y`

from the domain represented by`*this`

and returns the size of the updated domain.`operator <=`

[*operator member function*]`int operator <= (const int y);`

This member function removes all elements being larger than

`y`

from the domain represented by`*this`

and returns the size of the updated domain.`operator >=`

[*operator member function*]`int operator >= (const int y);`

This member function removes all elements being smaller than

`y`

from the domain represented by`*this`

and returns the size of the updated domain.

`intersectWithBool`

[*member function*]`int intersectWithBool(void);`

This member function intersects the current domain with the domain and produces the following return value.

return value

meaning

-2

The resulting domain is empty.

-1

The resulting domain is

otherwise

The remaining element is returned.

`constrainBool`

[*member function*]`int constrainBool(void);`

This member function intersects the current domain with the domain and returns the size of resulting domain.

`isIn`

[*member function*]`OZ_Boolean isIn(int i) const;`

This member function returns

`OZ_TRUE`

if`i`

is contained in the domain represented by`*this`

. Otherwise it returns`OZ_FALSE`

.`copyExtension`

[*member function*]`void copyExtension(void);`

This member function replaces the current extension of the domain representation by a copy of it.

`disposeExtension`

[*member function*]`void disposeExtension(void);`

This member function frees the heap memory occupied by the extension of the domain.

`toString`

[*constant member function*]`char * toString(void) const;`

Returns a textual representation of the finite domain pointing to a static array of

`char`

s.

<< Prev | - Up - | Next >> |

Tobias Müller

Version 1.4.0 (20080702)