Generated on Tue Jul 27 2010 21:59:25 for Gecode by doxygen 1.7.1

Gecode::ArgArrayBase< T > Class Template Reference

Base-class for argument arrays. More...

#include <array.hpp>

List of all members.

Protected Member Functions

T * allocate (int n)
 Allocate memory for n elements.
void resize (int i)
 Resize to hold at least i additional elements.
template<class A >
concat (const ArgArrayBase< T > &x) const
 Return this array concatenated with x.
template<class A >
concat (const T &x) const
 Return this array concatenated with x.
template<class A >
A & append (const T &x)
 Insert a new element x at the end of the array (increase size by 1).
template<class A >
A & append (const ArgArrayBase< T > &x)
 Append x to the end of the array.
template<class A >
slice (int start, int inc=1, int n=-1)

Protected Attributes

int n
 Number of elements.
int capacity
 Allocated size of the array.
T * a
 Element array.
onstack [onstack_size]
 In-array storage for elements.

Static Protected Attributes

static const int onstack_size = 16
 How many elements are possible inside array.

Related Functions

(Note that these are not member functions.)



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

Constructors and initialization



 ArgArrayBase (void)
 Allocate empty array.
 ArgArrayBase (int n)
 Allocate array with n elements.
 ArgArrayBase (const ArgArrayBase< T > &a)
 Initialize from argument array a (copy elements).
const ArgArrayBase< T > & operator= (const ArgArrayBase< T > &a)
 Initialize from view array a (copy elements).

Array size



int size (void) const
 Return size of array (number of elements).

Array elements



T & operator[] (int i)
 Return element at position i.
const T & operator[] (int i) const
 Return element at position i.

Destructor



 ~ArgArrayBase (void)
 Destructor.

Detailed Description

template<class T>
class Gecode::ArgArrayBase< T >

Base-class for argument arrays.

Argument arrays are used as convenient mechanism of passing arguments when calling functions as they combine both the size and the elements of an array. For a small number of elements, memory is allocated by creating an argument array object. Otherwise the memory is allocated from the heap.

This base-class is not to be used directly, use PrimArgArray for argument arrays of primitive types, VarArgArray for argument arrays storing variables, and ArgArray for any other type.

Definition at line 408 of file array.hpp.


Constructor & Destructor Documentation

template<class T >
Gecode::ArgArrayBase< T >::ArgArrayBase ( void   )  [inline]

Allocate empty array.

Definition at line 1331 of file array.hpp.

template<class T >
Gecode::ArgArrayBase< T >::ArgArrayBase ( int  n  )  [inline, explicit]

Allocate array with n elements.

Definition at line 1336 of file array.hpp.

template<class T>
Gecode::ArgArrayBase< T >::ArgArrayBase ( const ArgArrayBase< T > &  a  )  [inline]

Initialize from argument array a (copy elements).

Definition at line 1341 of file array.hpp.

template<class T >
Gecode::ArgArrayBase< T >::~ArgArrayBase ( void   )  [inline]

Destructor.

Definition at line 1348 of file array.hpp.


Member Function Documentation

template<class T >
T * Gecode::ArgArrayBase< T >::allocate ( int  n  )  [inline, protected]

Allocate memory for n elements.

Definition at line 1307 of file array.hpp.

template<class T >
void Gecode::ArgArrayBase< T >::resize ( int  i  )  [inline, protected]

Resize to hold at least i additional elements.

Definition at line 1314 of file array.hpp.

template<class T>
template<class A >
A Gecode::ArgArrayBase< T >::concat ( const ArgArrayBase< T > &  x  )  const [inline, protected]

Return this array concatenated with x.

Definition at line 1425 of file array.hpp.

template<class T>
template<class A >
A Gecode::ArgArrayBase< T >::concat ( const T &  x  )  const [inline, protected]

Return this array concatenated with x.

Definition at line 1436 of file array.hpp.

template<class T>
template<class A >
A & Gecode::ArgArrayBase< T >::append ( const T &  x  )  [inline, protected]

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

Definition at line 1408 of file array.hpp.

template<class T>
template<class A >
A & Gecode::ArgArrayBase< T >::append ( const ArgArrayBase< T > &  x  )  [inline, protected]

Append x to the end of the array.

Definition at line 1416 of file array.hpp.

template<class T >
template<class A >
A Gecode::ArgArrayBase< T >::slice ( int  start,
int  inc = 1,
int  n = -1 
) [protected]

Return slice $y$ of length at most n such that forall $0\leq i<n$, $y_i=x_{\text{start}+i\cdot\text{inc}}$

If n is -1, then all possible elements starting from start with increment inc are returned.

Reimplemented in Gecode::PrimArgArray< T >, Gecode::ArgArray< T >, Gecode::VarArgArray< Var >, Gecode::PrimArgArray< int >, Gecode::ArgArray< IntSet >, Gecode::VarArgArray< SetVar >, Gecode::VarArgArray< IntVar >, and Gecode::VarArgArray< BoolVar >.

Definition at line 1389 of file array.hpp.

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

Initialize from view array a (copy elements).

Definition at line 1355 of file array.hpp.

template<class T >
int Gecode::ArgArrayBase< T >::size ( void   )  const [inline]

Return size of array (number of elements).

Definition at line 1369 of file array.hpp.

template<class T >
T & Gecode::ArgArrayBase< T >::operator[] ( int  i  )  [inline]

Return element at position i.

Definition at line 1375 of file array.hpp.

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

Return element at position i.

Definition at line 1382 of file array.hpp.


Friends And Related Function Documentation

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

Print array elements enclosed in curly brackets.

Definition at line 1802 of file array.hpp.


Member Data Documentation

template<class T>
int Gecode::ArgArrayBase< T >::n [protected]

Number of elements.

Definition at line 411 of file array.hpp.

template<class T>
int Gecode::ArgArrayBase< T >::capacity [protected]

Allocated size of the array.

Definition at line 413 of file array.hpp.

template<class T>
T* Gecode::ArgArrayBase< T >::a [protected]

Element array.

Definition at line 415 of file array.hpp.

template<class T>
const int Gecode::ArgArrayBase< T >::onstack_size = 16 [static, protected]

How many elements are possible inside array.

Definition at line 417 of file array.hpp.

template<class T>
T Gecode::ArgArrayBase< T >::onstack[onstack_size] [protected]

In-array storage for elements.

Definition at line 419 of file array.hpp.


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