Skip to main content
FRAMES NO FRAMES

Class IloNumSet

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

An instance of this class represents a set of numeric values. The same numeric value will not appear more than once in a set. The elements of a set are not ordered. The class IloNumSet::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 IloNumArray for sets, instead of this class.

Most member functions in this class contain assert statements. For an explanation of the macro NDEBUG (a way to turn on or turn off these assert statements), see the concept Assert and NDEBUG.

See Also:

Method Summary
public voidadd(IloNumSet set)
public voidadd(IloNum elt)
public IloBoolcontains(IloNumSet set) const
public IloBoolcontains(IloNum elt) const
public voidempty()
public IloNumgetFirst() const
public IloNumSetI *getImpl() const
public IloNumgetLast() const
public IloNumgetNext(IloNum value, IloInt offset=1) const
public IloNumgetNextC(IloNum value, IloInt offset=1) const
public IloNumgetPrevious(IloNum value, IloInt offset=1) const
public IloNumgetPreviousC(IloNum value, IloInt offset=1) const
public IloIntgetSize() const
public IloNumSet(const IloEnv env, const IloNumArray array, IloBool withIndex=IloFalse)
public IloNumSet(const IloEnv env, IloBool withIndex=IloFalse)
public IloNumSet(IloNumSetI * impl=0)
public IloBoolintersects(IloNumSet set) const
public voidremove(IloNumSet set)
public voidremove(IloNum elt)
public voidsetIntersection(IloNumSet set)
public voidsetIntersection(IloNum elt)
Inherited Methods from IloNumCollection
getImpl, getValue, IloNumCollection
Inherited Methods from IloDiscreteDataCollection
getImpl, getIndex, getIndex, getIndex, getIndex, getIndex, getSize, IloDiscreteDataCollection, IloDiscreteDataCollection, isOrdered, isReversed, isSorted, iterator
Inherited Methods from IloDataCollection
display, end, getEnv, getName, isIntRange, isIntSet, isNumRange, isNumSet, isSymbolSet, isTupleSet, sort, sort, sort, sort
Inner Class
IloNumSet::Iterator This class is an iterator that traverses the elements of a finite set of numeric values.
Method Detail

IloNumSet

public IloNumSet(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.

Parameters:

env
The environment in which you want to create the array.
array
An array of elements for the float set.
withIndex
A Boolean to specify whether to activate hash tables with this array.

IloNumSet

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

This constructor creates an empty set (no elements) in the environment env. You must use the member function IloNumSet::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.

Parameters:

env
The environment in which you want to create the empty array.
withIndex
A Boolean to specify whether to activate hash tables with this array.

IloNumSet

public IloNumSet(IloNumSetI * impl=0)

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

Parameters:

impl
A pointer to the implementation object of this class.

add

public void add(IloNumSet set)

This member function adds set to the invoking set. By "adds," we mean 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.

Parameters:

set
Need description here.

add

public void add(IloNum elt)

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

Parameters:

elt
Need description here.

contains

public IloBool contains(IloNumSet 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 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 set is not precisely set.

Parameters:

set
The set containing all the values to be tested.

Returns:

A Boolean value specifying whether set is an element of the invoking set.

contains

public IloBool contains(IloNum 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.

Parameters:

elt
The element to be looked for in the set.

Returns:

A Boolean value specifying whether elt is an element of the invoking set.

empty

public void empty()

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


getFirst

public IloNum getFirst() const

Returns the first item of the collection.

See Also:

Returns:

Returns the first item of the collection.

getImpl

public IloNumSetI * getImpl() const

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

Returns:

A pointer to the implementation object.

getLast

public IloNum getLast() const

Returns the last item of the collection.

See Also:

Returns:

Returns the last item of the collection.

getNext

public IloNum getNext(IloNum 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:

Parameters:

value
The value you want to return the value next to.

Returns:

The value next to the given argument in the set.

getNextC

public IloNum getNextC(IloNum 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:

Parameters:

value
The value you want to return the value next to.

Returns:

The value next to the given argument in the set.

getPrevious

public IloNum getPrevious(IloNum 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:

Parameters:

value
The value you want to return the value previous to.

Returns:

The value previous to the given argument in the set.

getPreviousC

public IloNum getPreviousC(IloNum 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:

Parameters:

value
The value you want to return the value previous to.

Returns:

The value previous to the given argument in the set.

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).

Returns:

An integer representing the size of the invoking set.

intersects

public IloBool intersects(IloNumSet 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).

Parameters:

set
The set containing all the values to be tested.

Returns:

A Boolean value specifying whether set is an element of the invoking set.

remove

public void remove(IloNumSet set)

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

Parameters:

set
Need description here.

remove

public void remove(IloNum elt)

This member function removes elt from the invoking set.

If the set does not contain this element, no error is raised

Parameters:

elt
Need description here.

setIntersection

public void setIntersection(IloNumSet 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.

Parameters:

set
Need description here.

setIntersection

public void setIntersection(IloNum 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.

Parameters:

elt
Need description here.