Generated on Mon May 10 06:46:54 2010 for Gecode by doxygen 1.6.3

Gecode::VarArray< Var > Class Template Reference
[Programming variables]

Variable arrays More...

#include <array.hpp>

List of all members.

Protected Attributes

int n
 Number of variables (size).
int capacity
 Allocated size of the array.
Var * x
 Array of variables.

Related Functions

(Note that these are not member functions.)



template<class Char , class Traits , class Var >
std::basic_ostream< Char,
Traits > & 
operator<< (std::basic_ostream< Char, Traits > &os, const VarArray< Var > &x)
 Print array elements enclosed in curly brackets.

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]

Default constructor (array of size 0).

Definition at line 577 of file array.hpp.

template<class Var >
Gecode::VarArray< Var >::VarArray ( Space home,
int  m 
) [inline]

Allocate array with m variables.

Definition at line 581 of file array.hpp.

template<class Var>
Gecode::VarArray< Var >::VarArray ( Space home,
const VarArgArray< Var > &  a 
) [inline]

Initialize from variable argument array a (copy elements).

Definition at line 1267 of file array.hpp.

template<class Var>
Gecode::VarArray< Var >::VarArray ( const VarArray< Var > &  a  )  [inline]

Initialize from variable array a (share elements).

Definition at line 589 of file array.hpp.

template<class Var >
Gecode::VarArray< Var >::~VarArray ( void   )  [inline]

Destructor.

Definition at line 595 of file array.hpp.


Member Function Documentation

template<class Var>
const VarArray< Var > & Gecode::VarArray< Var >::operator= ( const VarArray< Var > &  a  )  [inline]

Initialize from variable array a (share elements).

Definition at line 604 of file array.hpp.

template<class Var >
int Gecode::VarArray< Var >::size ( void   )  const [inline]

Return size of array (number of elements).

Definition at line 611 of file array.hpp.

template<class Var >
void Gecode::VarArray< Var >::resize ( Space home,
int  m 
) [inline]

Insert or remove (uninitialized!) elements at the end such that size becomes m.

Definition at line 617 of file array.hpp.

template<class Var >
Var & Gecode::VarArray< Var >::operator[] ( int  i  )  [inline]

Return variable at position i.

Definition at line 650 of file array.hpp.

template<class Var >
const Var & Gecode::VarArray< Var >::operator[] ( int  i  )  const [inline]

Return variable at position i.

Definition at line 657 of file array.hpp.

template<class Var>
void Gecode::VarArray< Var >::add ( Space home,
const Var &  v 
) [inline]

Insert a new element v at the end of the array (increase size by 1).

Definition at line 664 of file array.hpp.

template<class Var>
void Gecode::VarArray< Var >::update ( Space home,
bool  share,
VarArray< Var > &  a 
) [inline]

Update array to be a clone of array a.

If share is true, sharing is retained for all shared data structures. Otherwise, for each of them an independent copy is created.

Definition at line 671 of file array.hpp.


Friends And Related Function Documentation

template<class Char , class Traits , class Var >
std::basic_ostream< Char, Traits > & operator<< ( std::basic_ostream< Char, Traits > &  os,
const VarArray< Var > &  x 
) [related]

Print array elements enclosed in curly brackets.

Definition at line 1285 of file array.hpp.


Member Data Documentation

template<class Var>
int Gecode::VarArray< Var >::n [protected]

Number of variables (size).

Definition at line 68 of file array.hpp.

template<class Var>
int Gecode::VarArray< Var >::capacity [protected]

Allocated size of the array.

Definition at line 70 of file array.hpp.

template<class Var>
Var* Gecode::VarArray< Var >::x [protected]

Array of variables.

Definition at line 72 of file array.hpp.


The documentation for this class was generated from the following file: