VGServer::TpArray< Tp > Class Template Reference

TpArray is a more simple template array than std::vector. More...

#include <TpArray.h>

List of all members.

Public Types

typedef const Tp * const_iterator
 for const iterator returns
typedef const value_type const_pointer
 a read-only pointer possibly to an object of the value_type
typedef const value_typeconst_reference
 a read-only reference to an object of the value_type
typedef Tp * iterator
 as in STL an iterator is just about the same as a pointer.
typedef value_typepointer
 a read-write pointer possibly to an object of the value_type
typedef value_typereference
 a reference to an object of the value_type
typedef unsigned int size_type
 for size values
typedef TpArray< Tp > tparray
 the type of this container array, thus our own type
typedef Tp value_type
 the value we are talking about here

Public Member Functions

const_iterator begin () const
 return a read-only constant pointer to the first element
iterator begin ()
 return a read/write pointer to the first element
size_type capacity () const
 return the capacity (available elements before more need to be allocated)
void clear ()
 clear destroys all objects in the array and resets it's size
bool empty () const
 returns true if the array is empty
const_iterator end () const
 return a read-only constant pointer just past the last valid element
iterator end ()
 return a read/write pointer just past the last valid element
const_reference last () const
 return a reference to the last valid object in the array
reference last ()
 return a reference to the last valid object in the array
reference new_back ()
 this function constructs a default object at the end of the array, growing it if necessary and returns a reference to the new object.
tparrayoperator= (const tparray &other)
 assignment operator: destroys all contained objects and creates copies of those in the other array
const_reference operator[] (size_type n) const
 easy and fast read-only subscription access
reference operator[] (size_type n)
 easy and fast subscription access to an element of the array
void push_back (const_reference obj)
 this function copy-constructs a new object at the end of the array from the given object reference.
void reserve (size_type n)
 make sure at least n elements are avaiable before more need to be allocated.
void set_size (size_type n)
 manually sets the array size after direct loading
size_type size () const
 return currently used number of elements in the array
void swap (tparray &other)
 swaps this array's contents with the other array object
 TpArray (const tparray &other)
 copy constructor: allocates a new array and copies each element
 TpArray (size_type _reserve)
 allocate an array and possibly reverse available space
 TpArray ()
 initialize an empty array
 ~TpArray ()
 calls the destructor for all contained elements and frees the array


Detailed Description

template<typename Tp>
class VGServer::TpArray< Tp >

TpArray is a more simple template array than std::vector.

Most importantly: it does not grow quadratic (this gets annoying in the range of 512MB vector sizes). The code is based on Sgi's std::vector's.

Definition at line 16 of file TpArray.h.


Member Typedef Documentation

template<typename Tp>
typedef const Tp* VGServer::TpArray< Tp >::const_iterator

for const iterator returns

Definition at line 43 of file TpArray.h.

template<typename Tp>
typedef const value_type VGServer::TpArray< Tp >::const_pointer

a read-only pointer possibly to an object of the value_type

Definition at line 37 of file TpArray.h.

template<typename Tp>
typedef const value_type& VGServer::TpArray< Tp >::const_reference

a read-only reference to an object of the value_type

Definition at line 31 of file TpArray.h.

template<typename Tp>
typedef Tp* VGServer::TpArray< Tp >::iterator

as in STL an iterator is just about the same as a pointer.

Definition at line 40 of file TpArray.h.

template<typename Tp>
typedef value_type* VGServer::TpArray< Tp >::pointer

a read-write pointer possibly to an object of the value_type

Definition at line 34 of file TpArray.h.

template<typename Tp>
typedef value_type& VGServer::TpArray< Tp >::reference

a reference to an object of the value_type

Definition at line 28 of file TpArray.h.

template<typename Tp>
typedef unsigned int VGServer::TpArray< Tp >::size_type

for size values

Definition at line 46 of file TpArray.h.

template<typename Tp>
typedef TpArray<Tp> VGServer::TpArray< Tp >::tparray

the type of this container array, thus our own type

Definition at line 22 of file TpArray.h.

template<typename Tp>
typedef Tp VGServer::TpArray< Tp >::value_type

the value we are talking about here

Definition at line 25 of file TpArray.h.


Constructor & Destructor Documentation

template<typename Tp>
VGServer::TpArray< Tp >::TpArray (  )  [inline]

initialize an empty array

Definition at line 60 of file TpArray.h.

template<typename Tp>
VGServer::TpArray< Tp >::TpArray ( size_type  _reserve  )  [inline, explicit]

allocate an array and possibly reverse available space

Definition at line 66 of file TpArray.h.

template<typename Tp>
VGServer::TpArray< Tp >::TpArray ( const tparray other  )  [inline]

copy constructor: allocates a new array and copies each element

Definition at line 73 of file TpArray.h.

template<typename Tp>
VGServer::TpArray< Tp >::~TpArray (  )  [inline]

calls the destructor for all contained elements and frees the array

Definition at line 87 of file TpArray.h.


Member Function Documentation

template<typename Tp>
const_iterator VGServer::TpArray< Tp >::begin (  )  const [inline]

return a read-only constant pointer to the first element

Definition at line 161 of file TpArray.h.

template<typename Tp>
iterator VGServer::TpArray< Tp >::begin (  )  [inline]

return a read/write pointer to the first element

Definition at line 157 of file TpArray.h.

Referenced by VGServer::TpArray< VGServer::GraphData::Vertex >::clear(), VGServer::TpArray< VGServer::GraphData::Vertex >::empty(), VGServer::TpArray< VGServer::GraphData::Vertex >::operator=(), VGServer::TpArray< VGServer::GraphData::Vertex >::operator[](), and VGServer::TpArray< VGServer::GraphData::Vertex >::TpArray().

template<typename Tp>
size_type VGServer::TpArray< Tp >::capacity (  )  const [inline]

return the capacity (available elements before more need to be allocated)

Definition at line 118 of file TpArray.h.

Referenced by VGServer::TpArray< VGServer::GraphData::Vertex >::new_back(), VGServer::TpArray< VGServer::GraphData::Vertex >::push_back(), VGServer::TpArray< VGServer::GraphData::Vertex >::reserve(), and VGServer::TpArray< VGServer::GraphData::Vertex >::set_size().

template<typename Tp>
void VGServer::TpArray< Tp >::clear (  )  [inline]

clear destroys all objects in the array and resets it's size

Definition at line 173 of file TpArray.h.

Referenced by VGServer::TpArray< VGServer::GraphData::Vertex >::operator=(), and VGServer::TpArray< VGServer::GraphData::Vertex >::~TpArray().

template<typename Tp>
bool VGServer::TpArray< Tp >::empty (  )  const [inline]

returns true if the array is empty

Definition at line 126 of file TpArray.h.

template<typename Tp>
const_iterator VGServer::TpArray< Tp >::end (  )  const [inline]

return a read-only constant pointer just past the last valid element

Definition at line 169 of file TpArray.h.

template<typename Tp>
iterator VGServer::TpArray< Tp >::end (  )  [inline]

return a read/write pointer just past the last valid element

Definition at line 165 of file TpArray.h.

Referenced by VGServer::TpArray< VGServer::GraphData::Vertex >::clear(), VGServer::TpArray< VGServer::GraphData::Vertex >::empty(), VGServer::TpArray< VGServer::GraphData::Vertex >::last(), VGServer::TpArray< VGServer::GraphData::Vertex >::operator=(), and VGServer::TpArray< VGServer::GraphData::Vertex >::TpArray().

template<typename Tp>
const_reference VGServer::TpArray< Tp >::last (  )  const [inline]

return a reference to the last valid object in the array

Definition at line 194 of file TpArray.h.

template<typename Tp>
reference VGServer::TpArray< Tp >::last (  )  [inline]

return a reference to the last valid object in the array

Definition at line 190 of file TpArray.h.

template<typename Tp>
reference VGServer::TpArray< Tp >::new_back (  )  [inline]

this function constructs a default object at the end of the array, growing it if necessary and returns a reference to the new object.

This is the main function to be used when building the data. Thus no temporary objects are created as with STL's push_back(reference).

Definition at line 201 of file TpArray.h.

Referenced by VGServer::GraphData::applyChangelist().

template<typename Tp>
tparray& VGServer::TpArray< Tp >::operator= ( const tparray other  )  [inline]

assignment operator: destroys all contained objects and creates copies of those in the other array

Definition at line 99 of file TpArray.h.

template<typename Tp>
const_reference VGServer::TpArray< Tp >::operator[] ( size_type  n  )  const [inline]

easy and fast read-only subscription access

Definition at line 186 of file TpArray.h.

template<typename Tp>
reference VGServer::TpArray< Tp >::operator[] ( size_type  n  )  [inline]

easy and fast subscription access to an element of the array

Definition at line 182 of file TpArray.h.

template<typename Tp>
void VGServer::TpArray< Tp >::push_back ( const_reference  obj  )  [inline]

this function copy-constructs a new object at the end of the array from the given object reference.

Therefore this method requires a usually temporary source object.

Definition at line 213 of file TpArray.h.

template<typename Tp>
void VGServer::TpArray< Tp >::reserve ( size_type  n  )  [inline]

make sure at least n elements are avaiable before more need to be allocated.

Definition at line 131 of file TpArray.h.

Referenced by VGServer::GraphData::applyChangelist(), VGServer::TpArray< VGServer::GraphData::Vertex >::new_back(), VGServer::TpArray< VGServer::GraphData::Vertex >::operator=(), VGServer::TpArray< VGServer::GraphData::Vertex >::push_back(), and VGServer::TpArray< VGServer::GraphData::Vertex >::TpArray().

template<typename Tp>
void VGServer::TpArray< Tp >::set_size ( size_type  n  )  [inline]

manually sets the array size after direct loading

Definition at line 153 of file TpArray.h.

Referenced by VGServer::TpArray< VGServer::GraphData::Vertex >::operator=(), and VGServer::TpArray< VGServer::GraphData::Vertex >::TpArray().

template<typename Tp>
size_type VGServer::TpArray< Tp >::size (  )  const [inline]

return currently used number of elements in the array

Definition at line 122 of file TpArray.h.

Referenced by VGServer::GraphData::applyChangelist(), VGServer::TpArray< VGServer::GraphData::Vertex >::last(), VGServer::TpArray< VGServer::GraphData::Vertex >::new_back(), VGServer::TpArray< VGServer::GraphData::Vertex >::operator=(), VGServer::TpArray< VGServer::GraphData::Vertex >::operator[](), VGServer::TpArray< VGServer::GraphData::Vertex >::push_back(), VGServer::TpArray< VGServer::GraphData::Vertex >::reserve(), and VGServer::TpArray< VGServer::GraphData::Vertex >::TpArray().

template<typename Tp>
void VGServer::TpArray< Tp >::swap ( tparray other  )  [inline]

swaps this array's contents with the other array object

Definition at line 222 of file TpArray.h.


The documentation for this class was generated from the following file:
Generated on Wed Sep 27 14:34:01 2006 for VGServer by  doxygen 1.4.7