Generated on Sat Aug 25 2012 03:33:03 for Gecode by doxygen 1.8.1.2
Gecode::ArgArrayBase< T > Class Template Reference

Base-class for argument arrays. More...

#include <array.hpp>

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.

Associated types

typedef T value_type
 Type of the view stored in this array.
typedef T & reference
 Type of a reference to the value type.
typedef const T & const_reference
 Type of a constant reference to the value type.
typedef T * pointer
 Type of a pointer to the value type.
typedef const T * const_pointer
 Type of a read-only pointer to the value type.
typedef T * iterator
 Type of the iterator used to iterate through this array's elements.
typedef const T * const_iterator
 Type of the iterator used to iterate read-only through this array's elements.
typedef std::reverse_iterator
< T * > 
reverse_iterator
 Type of the iterator used to iterate backwards through this array's elements.
typedef std::reverse_iterator
< const T * > 
const_reverse_iterator
 Type of the iterator used to iterate backwards and read-only through this array's elements.

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.

Array iteration

iterator begin (void)
 Return an iterator at the beginning of the array.
const_iterator begin (void) const
 Return a read-only iterator at the beginning of the array.
iterator end (void)
 Return an iterator past the end of the array.
const_iterator end (void) const
 Return a read-only iterator past the end of the array.
reverse_iterator rbegin (void)
 Return a reverse iterator at the end of the array.
const_reverse_iterator rbegin (void) const
 Return a reverse and read-only iterator at the end of the array.
reverse_iterator rend (void)
 Return a reverse iterator past the beginning of the array.
const_reverse_iterator rend (void) const
 Return a reverse and read-only iterator past the beginning of the array.

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 520 of file array.hpp.

Member Typedef Documentation

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

Type of the view stored in this array.

Definition at line 559 of file array.hpp.

template<class T>
typedef T& Gecode::ArgArrayBase< T >::reference

Type of a reference to the value type.

Definition at line 561 of file array.hpp.

template<class T>
typedef const T& Gecode::ArgArrayBase< T >::const_reference

Type of a constant reference to the value type.

Definition at line 563 of file array.hpp.

template<class T>
typedef T* Gecode::ArgArrayBase< T >::pointer

Type of a pointer to the value type.

Definition at line 565 of file array.hpp.

template<class T>
typedef const T* Gecode::ArgArrayBase< T >::const_pointer

Type of a read-only pointer to the value type.

Definition at line 567 of file array.hpp.

template<class T>
typedef T* Gecode::ArgArrayBase< T >::iterator

Type of the iterator used to iterate through this array's elements.

Definition at line 569 of file array.hpp.

template<class T>
typedef const T* Gecode::ArgArrayBase< T >::const_iterator

Type of the iterator used to iterate read-only through this array's elements.

Definition at line 571 of file array.hpp.

template<class T>
typedef std::reverse_iterator<T*> Gecode::ArgArrayBase< T >::reverse_iterator

Type of the iterator used to iterate backwards through this array's elements.

Definition at line 573 of file array.hpp.

template<class T>
typedef std::reverse_iterator<const T*> Gecode::ArgArrayBase< T >::const_reverse_iterator

Type of the iterator used to iterate backwards and read-only through this array's elements.

Definition at line 575 of file array.hpp.

Constructor & Destructor Documentation

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

Allocate empty array.

Definition at line 1598 of file array.hpp.

template<class T >
Gecode::ArgArrayBase< T >::ArgArrayBase ( int  n)
inlineexplicit

Allocate array with n elements.

Definition at line 1603 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 1608 of file array.hpp.

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

Destructor.

Definition at line 1615 of file array.hpp.

Member Function Documentation

template<class T >
T * Gecode::ArgArrayBase< T >::allocate ( int  n)
inlineprotected

Allocate memory for n elements.

Definition at line 1574 of file array.hpp.

template<class T >
void Gecode::ArgArrayBase< T >::resize ( int  i)
inlineprotected

Resize to hold at least i additional elements.

Definition at line 1581 of file array.hpp.

template<class T>
template<class A >
A Gecode::ArgArrayBase< T >::concat ( const ArgArrayBase< T > &  x) const
inlineprotected

Return this array concatenated with x.

Definition at line 1740 of file array.hpp.

template<class T>
template<class A >
A Gecode::ArgArrayBase< T >::concat ( const T &  x) const
inlineprotected

Return this array concatenated with x.

Definition at line 1751 of file array.hpp.

template<class T>
template<class A >
A & Gecode::ArgArrayBase< T >::append ( const T &  x)
inlineprotected

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

Definition at line 1723 of file array.hpp.

template<class T>
template<class A >
A & Gecode::ArgArrayBase< T >::append ( const ArgArrayBase< T > &  x)
inlineprotected

Append x to the end of the array.

Definition at line 1731 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::VarArgArray< Var >, Gecode::VarArgArray< SetVar >, Gecode::VarArgArray< IntVar >, Gecode::VarArgArray< BoolVar >, Gecode::ArgArray< T >, Gecode::ArgArray< IntSet >, Gecode::PrimArgArray< T >, and Gecode::PrimArgArray< int >.

Definition at line 1704 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 1622 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 1636 of file array.hpp.

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

Return element at position i.

Definition at line 1642 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 1649 of file array.hpp.

template<class T >
ArgArrayBase< T >::iterator Gecode::ArgArrayBase< T >::begin ( void  )
inline

Return an iterator at the beginning of the array.

Definition at line 1656 of file array.hpp.

template<class T >
ArgArrayBase< T >::const_iterator Gecode::ArgArrayBase< T >::begin ( void  ) const
inline

Return a read-only iterator at the beginning of the array.

Definition at line 1662 of file array.hpp.

template<class T >
ArgArrayBase< T >::iterator Gecode::ArgArrayBase< T >::end ( void  )
inline

Return an iterator past the end of the array.

Definition at line 1668 of file array.hpp.

template<class T >
ArgArrayBase< T >::const_iterator Gecode::ArgArrayBase< T >::end ( void  ) const
inline

Return a read-only iterator past the end of the array.

Definition at line 1674 of file array.hpp.

template<class T >
ArgArrayBase< T >::reverse_iterator Gecode::ArgArrayBase< T >::rbegin ( void  )
inline

Return a reverse iterator at the end of the array.

Definition at line 1680 of file array.hpp.

template<class T >
ArgArrayBase< T >::const_reverse_iterator Gecode::ArgArrayBase< T >::rbegin ( void  ) const
inline

Return a reverse and read-only iterator at the end of the array.

Definition at line 1686 of file array.hpp.

template<class T >
ArgArrayBase< T >::reverse_iterator Gecode::ArgArrayBase< T >::rend ( void  )
inline

Return a reverse iterator past the beginning of the array.

Definition at line 1692 of file array.hpp.

template<class T >
ArgArrayBase< T >::const_reverse_iterator Gecode::ArgArrayBase< T >::rend ( void  ) const
inline

Return a reverse and read-only iterator past the beginning of the array.

Definition at line 1698 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 2117 of file array.hpp.

Member Data Documentation

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

Number of elements.

Definition at line 523 of file array.hpp.

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

Allocated size of the array.

Definition at line 525 of file array.hpp.

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

Element array.

Definition at line 527 of file array.hpp.

template<class T>
const int Gecode::ArgArrayBase< T >::onstack_size = 16
staticprotected

How many elements are possible inside array.

Definition at line 529 of file array.hpp.

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

In-array storage for elements.

Definition at line 531 of file array.hpp.


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