idaeim studio
 PVL: Parameter Value Language

Classes | Namespaces | Defines
Vectal.hh File Reference
#include <vector>
#include <iterator>
#include <string>
#include <stdexcept>
Include dependency graph for Vectal.hh:
This graph shows which files directly or indirectly include this file:


class  Vectal< T >::Const_Iterator
 A Const_Iterator provides a random access iterator for a const Vectal. More...
class  Vectal< T >::Const_Reverse_Iterator
 A Const_Reverse_Iterator provides a reverse random access iterator for a const Vectal. More...
class  Vectal< T >::Iterator
 An Iterator provides a random access iterator for a Vectal. More...
class  Vectal< T >::Reverse_Iterator
 A Reverse_Iterator provides a reverse random access iterator for a Vectal. More...
class  Vectal< T >
 A Vectal is a vector of virtual objects of any type. More...
struct  Vectal_ID
 A Vectal_ID provides a container for the static const ID value inheritied by every instantiation of a Vectal template. More...


namespace  idaeim


 Defines a memory allocation margin.
#define VECTAL_ID   "idaeim::Vectal (1.16 2004/10/26 10:23:05)"

Define Documentation

#define VECTAL_ID   "idaeim::Vectal (1.16 2004/10/26 10:23:05)"

Defines a memory allocation margin.

It is possible for two vectors to have continguous memory storage; i.e. one vector's storage immediately follows another's in memory address space. This can result in the end iterator for the first being equivalent to the begin iterator for the second. Typically this doesn't matter because the iterators for the two vectors are not considered to be comparable. However, when iterators for two vectors may be meaningfully compared (e.g. in the Depth_Iterator implementation for PVL:Aggregate and PVL::Array) then it is necessary to guarantee that the end interator can not correspond to any iterator value of another iterator. To accomplish this the memory allocated for a vector - its capacity - must be kept larger than the vector's contents - its size. Since this involves both a check and possible memory reallocation, the VECTAL_CAPACITY_MARGIN defines the margin to apply should a value insertion into the vector exhaust the available capacity; i.e. there will always be some extra capacity (and thus a margin of memory between potentially contiguously allocated vectors), and when reallocation is needed sufficient extra capacity for the specified number of values will be provided.

If the value of the symbol is zero, no extra capacity will be provided and the capacity check will be eliminated. While this usually results in Vectals with no excess memory allocated, it is not necessarily the most efficient as each unit of extra capacity is only the size of a pointer and each addition of a Vectal element may require a memory rellocation operation which could be avoided if sufficient capacity is already available and done in modestly larger chunks.