Gecode::VarArray< Var > Class Template Reference
Functionality by programming task » Programming variables

Variable arrays More...

`#include <array.hpp>`

## Protected Attributes

int | n
| Number of variables (size).
Var * | x
| Array of variables.

## Related Symbols

(Note that these are not member symbols.)
template<class T>
ArrayTraits< VarArray< T > >::ArgsType | operator+ (const VarArray< T > &x, const VarArgArray< T > &y)
template<class T>
ArrayTraits< VarArray< T > >::ArgsType | operator+ (const VarArray< T > &x, const VarArray< T > &y)
template<class T>
ArrayTraits< VarArray< T > >::ArgsType | operator+ (const VarArgArray< T > &x, const VarArray< T > &y)
template<class T>
ArrayTraits< VarArray< T > >::ArgsType | operator+ (const VarArray< T > &x, const T &y)
template<class T>
ArrayTraits< VarArray< T > >::ArgsType | operator+ (const T &x, const VarArray< T > &y)
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.

## Associated types

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

## 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).

## Array size

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

## Array elements

Var & | operator[] (int i)
| Return variable at position i.
const Var & | operator[] (int i) const
| Return variable at position i.
ArrayTraits< VarArgArray< Var > >::ArgsType | slice (int start, int inc=1, int n=-1)

## 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.
bool | assigned (void) const
| Test if all variables are assigned.

## Cloning

void | update (Space &home, 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 112 of file array.hpp.

## Member Typedef Documentation

## value_type

template<class Var>

typedef Var Gecode::VarArray< Var >::value_type

Type of the variable stored in this array.

Definition at line 122 of file array.hpp.

## reference

template<class Var>

typedef Var& Gecode::VarArray< Var >::reference

Type of a reference to the value type.

Definition at line 124 of file array.hpp.

## const_reference

template<class Var>

typedef const Var& Gecode::VarArray< Var >::const_reference

Type of a constant reference to the value type.

Definition at line 126 of file array.hpp.

## pointer

template<class Var>

typedef Var* Gecode::VarArray< Var >::pointer

Type of a pointer to the value type.

Definition at line 128 of file array.hpp.

## const_pointer

template<class Var>

typedef const Var* Gecode::VarArray< Var >::const_pointer

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

Definition at line 130 of file array.hpp.

## iterator

template<class Var>

typedef Var* Gecode::VarArray< Var >::iterator

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

Definition at line 132 of file array.hpp.

## const_iterator

template<class Var>

typedef const Var* Gecode::VarArray< Var >::const_iterator

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

Definition at line 134 of file array.hpp.

## reverse_iterator

template<class Var>

typedef std::reverse_iterator<Var*> Gecode::VarArray< Var >::reverse_iterator

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

Definition at line 136 of file array.hpp.

## const_reverse_iterator

template<class Var>

typedef std::reverse_iterator<const Var*> Gecode::VarArray< Var >::const_reverse_iterator

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

Definition at line 138 of file array.hpp.

## Constructor & Destructor Documentation

## VarArray() [1/4]

template<class Var>

Gecode::VarArray< Var >::VarArray | ( | void |  | ) |

inline

Default constructor (array of size 0).

Definition at line 901 of file array.hpp.

## VarArray() [2/4]

template<class Var>

Gecode::VarArray< Var >::VarArray | ( | Space & | home,
|  | int | m )

inline

Allocate array with m variables.

Definition at line 905 of file array.hpp.

## VarArray() [3/4]

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

## VarArray() [4/4]

template<class Var>

Gecode::VarArray< Var >::VarArray | ( | const VarArray< Var > & | a | ) |

inline

Initialize from variable array a (share elements).

Definition at line 913 of file array.hpp.

## Member Function Documentation

## operator=()

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

## size()

template<class Var>

int Gecode::VarArray< Var >::size | ( | void |  | ) | const

inline

Return size of array (number of elements).

Definition at line 926 of file array.hpp.

## operator[]() [1/2]

template<class Var>

Var & Gecode::VarArray< Var >::operator[] | ( | int | i | ) |

inline

Return variable at position i.

Definition at line 932 of file array.hpp.

## operator[]() [2/2]

template<class Var>

const Var & Gecode::VarArray< Var >::operator[] | ( | int | i | ) | const

inline

Return variable at position i.

Definition at line 939 of file array.hpp.

## slice()

template<class Var>

ArrayTraits< VarArgArray< Var > >::ArgsType Gecode::VarArray< Var >::slice | ( | int | start,
|  | int | inc = 1,
|  | int | n = -1 )

Return slice of length at most n such that forall ,

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

Definition at line 946 of file array.hpp.

## begin() [1/2]

template<class Var>

VarArray< Var >::iterator Gecode::VarArray< Var >::begin | ( | void |  | ) |

inline

Return an iterator at the beginning of the array.

Definition at line 965 of file array.hpp.

## begin() [2/2]

template<class Var>

VarArray< Var >::const_iterator Gecode::VarArray< Var >::begin | ( | void |  | ) | const

inline

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

Definition at line 971 of file array.hpp.

## end() [1/2]

template<class Var>

VarArray< Var >::iterator Gecode::VarArray< Var >::end | ( | void |  | ) |

inline

Return an iterator past the end of the array.

Definition at line 977 of file array.hpp.

## end() [2/2]

template<class Var>

VarArray< Var >::const_iterator Gecode::VarArray< Var >::end | ( | void |  | ) | const

inline

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

Definition at line 983 of file array.hpp.

## rbegin() [1/2]

template<class Var>

VarArray< Var >::reverse_iterator Gecode::VarArray< Var >::rbegin | ( | void |  | ) |

inline

Return a reverse iterator at the end of the array.

Definition at line 989 of file array.hpp.

## rbegin() [2/2]

template<class Var>

VarArray< Var >::const_reverse_iterator Gecode::VarArray< Var >::rbegin | ( | void |  | ) | const

inline

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

Definition at line 995 of file array.hpp.

## rend() [1/2]

template<class Var>

VarArray< Var >::reverse_iterator Gecode::VarArray< Var >::rend | ( | void |  | ) |

inline

Return a reverse iterator past the beginning of the array.

Definition at line 1001 of file array.hpp.

## rend() [2/2]

template<class Var>

VarArray< Var >::const_reverse_iterator Gecode::VarArray< Var >::rend | ( | void |  | ) | const

inline

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

Definition at line 1007 of file array.hpp.

## assigned()

template<class Var>

bool Gecode::VarArray< Var >::assigned | ( | void |  | ) | const

inline

Test if all variables are assigned.

Definition at line 1026 of file array.hpp.

## update()

template<class Var>

void Gecode::VarArray< Var >::update | ( | Space & | home,
|  | VarArray< Var > & | a )

inline

Update array to be a clone of array a.

Definition at line 1013 of file array.hpp.

## Friends And Related Symbol Documentation

## operator+() [1/5]

template<class T>

ArrayTraits< VarArray< T > >::ArgsType operator+ | ( | const VarArray< T > & | x,
|  | const VarArgArray< T > & | y )

related

Concatenate x and y and return result

## operator+() [2/5]

template<class T>

ArrayTraits< VarArray< T > >::ArgsType operator+ | ( | const VarArray< T > & | x,
|  | const VarArray< T > & | y )

related

Concatenate x and y and return result

## operator+() [3/5]

template<class T>

ArrayTraits< VarArray< T > >::ArgsType operator+ | ( | const VarArgArray< T > & | x,
|  | const VarArray< T > & | y )

related

Concatenate x and y and return result

## operator+() [4/5]

template<class T>

ArrayTraits< VarArray< T > >::ArgsType operator+ | ( | const VarArray< T > & | x,
|  | const T & | y )

related

Concatenate x and y and return result

## operator+() [5/5]

template<class T>

ArrayTraits< VarArray< T > >::ArgsType operator+ | ( | const T & | x,
|  | const VarArray< T > & | y )

related

Concatenate x and y and return result

## operator<<()

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

## Member Data Documentation

## n

template<class Var>

int Gecode::VarArray< Var >::n

protected

Number of variables (size).

Definition at line 115 of file array.hpp.

## x

template<class Var>

Var* Gecode::VarArray< Var >::x

protected

Array of variables.

Definition at line 117 of file array.hpp.

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

- gecode/kernel/data/array.hpp