跳至主内容
框架 无框架

类IlcIntArray

定义文件: ilcp/cpext.h
包含文件: <ilcp/cpextilcp/cpext.h
IlcIntArray的地图IlcIntArrayIlcIntArray
基本整数类的数组类。

IlcIntArray是基本整数类的数组类。 这是一个句柄类。

另请参阅:

方法概要
public IlcIntArrayI *getImpl() const
public IlcIntgetSize() const
public IlcIntArray(IlcInt * impl=0)
public IlcIntArray(IlcCPEngine solver, IlcInt size, IlcInt * values)
public IlcIntArray(IlcCPEngine solver, IlcInt size, IlcInt prototype=0)
public IlcIntArray(IlcCPEngine solver, IlcInt size, IlcInt exp0, IlcInt exp...)
public IlcIntExpoperator[](const IlcIntExp rank) const
public IlcInt &operator[](IlcInt i) const
方法详细信息

IlcIntArray

公共 'IlcIntArray(IlcInt* '内含=0)

该构造函数通过指向实现对象的指针创建一个句柄对象。 如果没有给出实现指针,则会创建一个空句柄。


IlcIntArray

publicIlcIntArray(IlcCPEngine solver,IlcInt size,IlcInt*values)

该构造函数创建了一个整数数组,其中包含数组 "values中的值。 参数 "size必须是数组 "values的长度;而且必须严格大于 0(零)。 CP 优化器没有保留指向数组 "values的指针。

下面是创建包含整数 1、3、2 的数组的一种方法。

 IlcInt值 [3];
 values[0] = 1;
 values[1] = 3;
 values[2] = 2;
 IlcIntArray array1(cp, 3, values);

IlcIntArray

public 'IlcIntArray( 'IlcCPEngine'求解器, 'IlcInt'尺寸, 'IlcInt'原型=0)

该构造函数创建一个包含 "size元素的数组。 参数 "size必须严格大于 0(零)。 该数组的元素被初始化为 "prototype的值。


IlcIntArray

public 'IlcIntArray( 'IlcCPEngine'求解器, 'IlcInt'尺寸, 'IlcInt'exp0, 'IlcInt'exp...' )

该构造函数接受数量可变的参数。 它的第二个参数 "size表示该构造函数将创建的数组的长度;"size必须是参数个数减一;它还必须严格大于 0(零)。 构造函数会创建一个数组,其中包含其他参数所指示的值。

下面是创建包含整数 1、3、2 的数组的另一种方法。

 IlcIntArray array2(求解器,3,1,3,2);
 

getImpl

publicIlcIntArrayI*getImpl() const

该成员函数返回一个指向调用句柄的实现对象的指针。


getSize

publicIlcInt getSize() const

该成员函数返回数组中元素的个数。


操作符[]

publicIlcIntExp operator[](constIlcIntExp rank) const

这个下标操作符返回一个受约束的整数表达式。 为了清楚起见,我们称 "A为调用数组。 当 "rank固定为 "i时,表达式的值为 "A[i]。 一般来说,表达式的域是值 "A[i]的集合,其中 "i位于 "rank的域中。


操作符[]

publicIlcInt&operator[]IlcInt i) const

此操作符将返回对位于 "i层的元素的引用。 该操作符可用于访问(即简单读取)元素或修改(即写入)元素。

下面是创建包含整数 1、3、2 的数组的另一种方法。

 IlcIntArray array5(cp, 3);
 array5[0] = 1;
 array5[1] = 3;
 array5[2] = 2;