Gecode::VarArray< Var > Class Template Reference
[Programming variables]
Variable arrays More...
#include <array.hpp>
Protected Attributes | |
int | n |
Number of variables (size). | |
int | capacity |
Allocated size of the array. | |
Var * | x |
Array of variables. | |
Constructors and initialization | |
| |
VarArray (void) | |
Default constructor (array of size 0). | |
VarArray (Space &home, int m) | |
Allocate array with m variables. | |
VarArray (Space &home, const VarArgArray< Var > &) | |
Initialize from variable argument array a (copy elements). | |
VarArray (const VarArray< Var > &a) | |
Initialize from variable array a (share elements). | |
const VarArray< Var > & | operator= (const VarArray< Var > &a) |
Initialize from variable array a (share elements). | |
~VarArray (void) | |
Destructor. | |
Array size | |
| |
int | size (void) const |
Return size of array (number of elements). | |
void | resize (Space &home, int m) |
Insert or remove (uninitialized!) elements at the end such that size becomes m. | |
Array elements | |
| |
Var & | operator[] (int i) |
Return variable at position i. | |
const Var & | operator[] (int i) const |
Return variable at position i. | |
void | add (Space &home, const Var &v) |
Insert a new element v at the end of the array (increase size by 1). | |
Cloning | |
| |
void | update (Space &, bool share, VarArray< Var > &a) |
Update array to be a clone of array a. |
Detailed Description
template<class Var>
class Gecode::VarArray< Var >
Variable arrays
Variable arrays store variables. They are typically used for storing the variables being part of a solution.
Never use them for temporary purposes, use argument arrays instead.
Variable arrays can be enlarged dynamically. For memory efficiency, the initial array is allocated in the space. When adding variables, it is automatically resized and allocated on the heap.
Definition at line 65 of file array.hpp.
Constructor & Destructor Documentation
template<class Var >
Gecode::VarArray< Var >::VarArray | ( | void | ) | [inline] |
template<class Var >
Gecode::VarArray< Var >::VarArray | ( | Space & | home, | |
int | m | |||
) | [inline] |
template<class Var>
Gecode::VarArray< Var >::VarArray | ( | Space & | home, | |
const VarArgArray< Var > & | a | |||
) | [inline] |
template<class Var>
Gecode::VarArray< Var >::VarArray | ( | const VarArray< Var > & | a | ) | [inline] |
template<class Var >
Gecode::VarArray< Var >::~VarArray | ( | void | ) | [inline] |
Member Function Documentation
template<class Var>
const VarArray< Var > & Gecode::VarArray< Var >::operator= | ( | const VarArray< Var > & | a | ) | [inline] |
template<class Var >
int Gecode::VarArray< Var >::size | ( | void | ) | const [inline] |
template<class Var >
void Gecode::VarArray< Var >::resize | ( | Space & | home, | |
int | m | |||
) | [inline] |
template<class Var >
Var & Gecode::VarArray< Var >::operator[] | ( | int | i | ) | [inline] |
template<class Var >
const Var & Gecode::VarArray< Var >::operator[] | ( | int | i | ) | const [inline] |
template<class Var>
void Gecode::VarArray< Var >::add | ( | Space & | home, | |
const Var & | v | |||
) | [inline] |
template<class Var>
void Gecode::VarArray< Var >::update | ( | Space & | home, | |
bool | share, | |||
VarArray< Var > & | a | |||
) | [inline] |
Member Data Documentation
template<class Var>
int Gecode::VarArray< Var >::n [protected] |
template<class Var>
int Gecode::VarArray< Var >::capacity [protected] |
template<class Var>
Var* Gecode::VarArray< Var >::x [protected] |
The documentation for this class was generated from the following file:
- gecode/kernel/array.hpp (Revision: 9779)