Skip to main content
FRAMES NO FRAMES

Class IlcIntSet

Definition file: ilcp/cpext.h
Include file: <ilcp/cpext.h>
Map of IlcIntSetIlcIntSetIlcIntSet
The handle class for sets of integers.

Finite sets of integers are instances of the handle class IlcIntSet. CP Optimizer provides an efficient, optimized implementation of finite sets as bit vectors. These finite sets are known as instances of the handle class IlcIntSet.

The elements of finite sets of type IlcIntSet are integers of type IlcInt. The implementation class for finite sets of integers is the undocumented class IlcIntSetI.

To traverse an existing finite set, either exhaustively or in search of an element, CP Optimizer provides iterators (such as instances of IlcIntSetIterator). An iterator is an object constructed from a data structure and contains a traversal state of this data structure.

Note
An IlcIntSet object should not contain an integer of value IlcIntTop. If an integer of value of IlcIntTop is included in an IlcIntSet object, an error can occur when iterating over the set.

See Also:

Method Summary
public IlcBooladd(IlcInt elt)
public IlcIntSetcopy() const
public IlcIntgetSize() const
public IlcIntSet(IlcCPEngine solver, IlcInt min, IlcInt max, IlcBool fullSet=IlcTrue)
public IlcIntSet(IlcCPEngine solver, const IlcIntArray array, IlcBool fullSet=IlcTrue)
public IlcBoolisIn(IlcInt elt) const
public IlcBoolremove(IlcInt elt)
Method Detail

IlcIntSet

public IlcIntSet(IlcCPEngine solver, IlcInt min, IlcInt max, IlcBool fullSet=IlcTrue)

This constructor creates a finite set of integers ranging from min to max included. If min is greater than max, then the empty set is created. If the argument fullset is equal to IlcTrue, the default value, the finite set will initially contain all its possible values. Otherwise, the finite set will initially be empty.


IlcIntSet

public IlcIntSet(IlcCPEngine solver, const IlcIntArray array, IlcBool fullSet=IlcTrue)

This constructor creates a finite set of integers containing the elements of array. If array contains multiple copies of a given value, that value will appear only one time in the newly created finite set. If the argument fullset is equal to IlcTrue, its default value, the finite set will initially contain all its possible values. Otherwise, the finite set will initially be empty. In any case, the possible elements of the finite set are exactly those elements in array.


add

public IlcBool add(IlcInt elt)

This member function adds elt to the invoking finite set if elt is a possible member of that set and if elt is not already in that set. When both conditions are met, this member function returns IlcTrue. Otherwise, it returns IlcFalse. The effects of this member function are reversible.


copy

public IlcIntSet copy() const

This member function creates and returns a finite set that contains the same elements as the invoking finite set.


getSize

public IlcInt getSize() const

This member function returns the size of a finite set. This member function is useful for testing whether the invoking finite set is empty or not.


isIn

public IlcBool isIn(IlcInt elt) const

This member function is a predicate that indicates whether or not elt is in the invoking finite set. It returns IlcTrue if elt is in the set; otherwise, it returns IlcFalse.


remove

public IlcBool remove(IlcInt elt)

This member function removes elt from the invoking finite set. This member function returns IlcFalse if elt was not in that invoking set. Otherwise, it returns IlcTrue. The effects of this member function are reversible.