NO FRAMES

Class IloIntSet

Definition file: ilconcert/iloset.h
An instance of this class offers a convenient way to represent a set of integer values.

An instance of this class offers a convenient way to represent a set of integer values as a constrained variable in Concert Technology.

An instance of this class represents a set of enumerated values. The same enumerated value will not appear more than once in a set. The elements of a set are not ordered. The class IloIntSet::Iterator offers you a way to traverse the elements of such a set.

If you are considering modeling issues where you want to represent repeated elements or where you want to exploit an indexed order among the elements, then you might want to look at the class IloAnyArray instead of this class for sets.

See Also:

Constructor Summary
public IloIntSet(const IloEnv env, const IloIntArray array, IloBool withIndex=IloFalse)
public IloIntSet(const IloEnv env, const IloNumArray array, IloBool withIndex=IloFalse)
public IloIntSet(const IloEnv env, IloBool withIndex=IloFalse)
public IloIntSet(IloIntSetI * impl=0)
Method Summary
public voidadd(IloIntSet set)
public voidadd(IloInt elt)
public IloBoolcontains(IloIntSet set) const
public IloBoolcontains(IloInt elt) const
public voidempty()
public IloIntgetFirst() const
public IloIntSetI *getImpl() const
public IloIntgetLast() const
public IloIntgetNext(IloInt value, IloInt offset=1) const
public IloIntgetNextC(IloInt value, IloInt offset=1) const
public IloIntgetPrevious(IloInt value, IloInt offset=1) const
public IloIntgetPreviousC(IloInt value, IloInt offset=1) const
public IloIntgetSize() const
public IloBoolintersects(IloIntSet set) const
public voidremove(IloIntSet set)
public voidremove(IloInt elt)
public voidsetIntersection(IloIntSet set)
public voidsetIntersection(IloInt elt)
Inner Class
IloIntSet::Iterator This class is an iterator that traverses the elements of a finite set of numeric values.
Constructor Detail

IloIntSet

public IloIntSet(const IloEnv env, const IloIntArray array, IloBool withIndex=IloFalse)

This constructor creates a set of integer values in the environment env from the elements in array. The optional flag withIndex corresponds to the activation or not of internal Hash Tables to improve speed of add/getIndex methods.


IloIntSet

public IloIntSet(const IloEnv env, const IloNumArray array, IloBool withIndex=IloFalse)

This constructor creates a set of numeric values in the environment env from the elements in array. The optional flag withIndex corresponds to the activation or not of internal Hash Tables to improve speed of add/getIndex methods.


IloIntSet

public IloIntSet(const IloEnv env, IloBool withIndex=IloFalse)

This constructor creates an empty set (no elements) in the environment env. You must use the member function IloIntSet::add to fill this set with elements. The optional flag withIndex corresponds to the activation or not of internal Hash Tables to improve speed of add/getIndex methods.


IloIntSet

public IloIntSet(IloIntSetI * impl=0)

This constructor creates a handle to a set of integer values from its implementation object.


Method Detail

add

public void add(IloIntSet set)

This member function adds set to the invoking set. Here, "adds" means that the invoking set becomes the union of its former elements and the elements of set.

To calculate the arithmetic sum of values in an array, use the function IloSum.


add

public void add(IloInt elt)

This member function adds elt to the invoking set. Here, "adds" means that the invoking set becomes the union of its former elements and the new elt.


contains

public IloBool contains(IloIntSet set) const

This member function returns a Boolean value (zero or one) that specifies whether set contains the invoking set. The value one specifies that the invoking set contains all the elements of set, and that the intersection of the invoking set with set is precisely set. The value zero specifies that the intersection of the invoking set and set is not precisely set.


contains

public IloBool contains(IloInt elt) const

This member function returns a Boolean value (zero or one) that specifies whether elt is an element of the invoking set. The value one specifies that the invoking set contains elt; the value zero specifies that the invoking set does not contain elt.


empty

public void empty()

This member function removes the elements from the invoking set. In other words, the invoking set becomes the empty set.


getFirst

public IloInt getFirst() const

Returns the first item of the collection.

Returns:

Returns the first item of the collection.

getImpl

public IloIntSetI * getImpl() const

This member function returns a pointer to the implementation object of the invoking set.


getLast

public IloInt getLast() const

Returns the last item of the collection.

Returns:

Returns the last item of the collection.

getNext

public IloInt getNext(IloInt value, IloInt offset=1) const

This method returns the value next to the given argument in the set.

If the given value does not exist, it throws an exception

If no value follows (that is, you are at the end of the set), it throws an exception.

See also getNextC, getPreviousC for circular search.

 S = {1,2,3,4}
 S.next(2,1) will return 3
 

Parameters:

value
Value used as an index.
offset
The offset to apply for the computation. An offset of 0 returns the same object.
 S = {1,2,3,4}
 S.next(2,1) will return 3
 

getNextC

public IloInt getNextC(IloInt value, IloInt offset=1) const

This method returns the value next to the given argument in the set.

If the given value does not exist, it throws an exception.

If no value follows (that is, you are at the end of the set), it will give you the first value (circular search).

See also getNext, getPrevious.

See Also:

Parameters:

value
Value used as an index.
offset
The offset to apply for the computation. An offset of 0 returns the same object.

getPrevious

public IloInt getPrevious(IloInt value, IloInt offset=1) const

This method returns the value previous to the given argument in the set.

If the given value does not exist, it throws an exception

If no value is previous (that is, you are at the beginning of the set), it throws an exception.

See also getNextC, getPreviousC for circular search.

See Also:

Parameters:

value
Value used as an index.
offset
The offset to apply for the computation. An offset of 0 returns the same object.

getPreviousC

public IloInt getPreviousC(IloInt value, IloInt offset=1) const

This method returns the value previous to the given argument in the set.

If the given value does not exist, it throws an exception.

If no value is previous (that is, you are at the beginning of the set), it will give you the last value (circular search).

See also getNext, getPrevious.

See Also:

Parameters:

value
Value used as an index.
offset
The offset to apply for the computation. An offset of 0 returns the same object.

getSize

public IloInt getSize() const

This member function returns an integer specifying the size of the invoking set (that is, how many elements it contains).


intersects

public IloBool intersects(IloIntSet set) const

This member function returns a Boolean value (zero or one) that specifies whether set intersects the invoking set. The value one specifies that the intersection of set and the invoking set is not empty (at least one element in common); the value zero specifies that the intersection of set and the invoking set is empty (no elements in common).


remove

public void remove(IloIntSet set)

This member function removes all the elements of set from the invoking set.


remove

public void remove(IloInt elt)

This member function removes elt from the invoking set.


setIntersection

public void setIntersection(IloIntSet set)

This member function changes the invoking set so that it includes only the elements of set. In other words, the invoking set becomes the intersection of its former elements with the elements of set.


setIntersection

public void setIntersection(IloInt elt)

This member function changes the invoking set so that it includes only the element specified by elt. In other words, the invoking set becomes the intersection of its former elements with elt.