Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

LightVector< TYPE > Class Template Reference

A lightweight vector. More...

#include <LightVector.hpp>

Collaboration diagram for LightVector< TYPE >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LightVector (TYPE *const values, int &size)
 Create a new LightVector wrapper around an ordinary array and a size variable.
 LightVector (TYPE *const values, int &size, int capacity)
int size () const
 Return the actual size and increment size afterwards by 1.
bool empty () const
void resize (int size)
 Set the size of the container to the given value.
void clear ()
TYPE operator[] (int index) const
 Get an entry of the container at a given index.
TYPE back () const
void setEntry (int index, TYPE value)
 Set the value of an entry to a given value.
void push_back (TYPE value)
void pop_back ()
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
TYPE * values () const
 Access the storage model of this vector directly.
int capacity () const
void destroy ()
 Destroy a LightVector and its storage.

Static Public Member Functions

static LightVector< TYPE > * create (int capacity, TYPE initValue=TYPE())
 Create and initialize a new LightVector with managed storage.

Private Attributes

TYPE *const m_values
int & m_size
int const m_capacity

Classes

class  const_iterator
class  iterator

Detailed Description

template<class TYPE>
class LightVector< TYPE >

A lightweight vector.

and thus allows for efficient operations.

You can use it mostly like a vector with fixed and not stored capacity (but not all methods are implemented yet).

Differences to STL vector are:

LightVector does not manage the memory, i.e., it does not release the array after destruction.

LightVector performs bounds checking if compiled with DEBUG_LEVEL > 0 and no bounds checking if compiled with DEBUG_LEVEL == 0.

LightVector is designed for elementary data types as its accessor methods return values (TYPE) and not const references to values (const TYPE&), because returning just values has shown much faster in some experiments.

Author:
Lars Schmidt-Thieme
Version:
1.0

Definition at line 50 of file LightVector.hpp.


Constructor & Destructor Documentation

template<class TYPE>
LightVector< TYPE >::LightVector TYPE *const   values,
int &  size
[inline]
 

Create a new LightVector wrapper around an ordinary array and a size variable.

Definition at line 56 of file LightVector.hpp.

Referenced by LightVector< TYPE >::create().

template<class TYPE>
LightVector< TYPE >::LightVector TYPE *const   values,
int &  size,
int  capacity
[inline]
 

Definition at line 57 of file LightVector.hpp.


Member Function Documentation

template<class TYPE>
TYPE LightVector< TYPE >::back  )  const [inline]
 

Definition at line 94 of file LightVector.hpp.

References LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

template<class TYPE>
const_iterator LightVector< TYPE >::begin  )  const [inline]
 

Definition at line 327 of file LightVector.hpp.

References LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

template<class TYPE>
iterator LightVector< TYPE >::begin  )  [inline]
 

Definition at line 323 of file LightVector.hpp.

References LightVector< TYPE >::m_capacity, and LightVector< TYPE >::m_values.

Referenced by cardinality_of_set_intersection(), main(), and set_intersection().

template<class TYPE>
int LightVector< TYPE >::capacity  )  const [inline]
 

Definition at line 352 of file LightVector.hpp.

References LightVector< TYPE >::m_capacity.

Referenced by main(), and set_intersection().

template<class TYPE>
void LightVector< TYPE >::clear  )  [inline]
 

Definition at line 81 of file LightVector.hpp.

References LightVector< TYPE >::m_size.

template<class TYPE>
static LightVector<TYPE>* LightVector< TYPE >::create int  capacity,
TYPE  initValue = TYPE()
[inline, static]
 

Create and initialize a new LightVector with managed storage.

Please note that this will NOT be released by delete (as delete only releases the view!), but only by a call to destroy.

Definition at line 360 of file LightVector.hpp.

References LightVector< TYPE >::LightVector(), and LightVector< TYPE >::values().

Referenced by main().

template<class TYPE>
void LightVector< TYPE >::destroy  )  [inline]
 

Destroy a LightVector and its storage.

This should only be called for LightVectors created by create.

Definition at line 375 of file LightVector.hpp.

References LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

template<class TYPE>
bool LightVector< TYPE >::empty  )  const [inline]
 

Definition at line 69 of file LightVector.hpp.

References LightVector< TYPE >::size().

template<class TYPE>
const_iterator LightVector< TYPE >::end  )  const [inline]
 

Definition at line 328 of file LightVector.hpp.

References LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

template<class TYPE>
iterator LightVector< TYPE >::end  )  [inline]
 

Definition at line 324 of file LightVector.hpp.

References LightVector< TYPE >::m_capacity, LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

Referenced by cardinality_of_set_intersection(), main(), and set_intersection().

template<class TYPE>
TYPE LightVector< TYPE >::operator[] int  index  )  const [inline]
 

Get an entry of the container at a given index.

Contrary to vector, it does only return a read-only value; use setEntry if you want to change an entry.

Definition at line 88 of file LightVector.hpp.

References LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

template<class TYPE>
void LightVector< TYPE >::pop_back  )  [inline]
 

Definition at line 113 of file LightVector.hpp.

References LightVector< TYPE >::m_size.

template<class TYPE>
void LightVector< TYPE >::push_back TYPE  value  )  [inline]
 

Definition at line 108 of file LightVector.hpp.

References LightVector< TYPE >::m_capacity, LightVector< TYPE >::m_size, and LightVector< TYPE >::m_values.

template<class TYPE>
void LightVector< TYPE >::resize int  size  )  [inline]
 

Set the size of the container to the given value.

Contrary to vector, it does not initialize newly-creared entries.

Definition at line 76 of file LightVector.hpp.

References LightVector< TYPE >::m_capacity, and LightVector< TYPE >::m_size.

Referenced by main().

template<class TYPE>
void LightVector< TYPE >::setEntry int  index,
TYPE  value
[inline]
 

Set the value of an entry to a given value.

Definition at line 102 of file LightVector.hpp.

References LightVector< TYPE >::m_capacity, and LightVector< TYPE >::m_values.

template<class TYPE>
int LightVector< TYPE >::size  )  const [inline]
 

Return the actual size and increment size afterwards by 1.

Contrary to vector, it does only return a read-only value; use resize if you want to change the size.

Definition at line 67 of file LightVector.hpp.

References LightVector< TYPE >::m_size.

Referenced by cardinality_of_set_intersection(), LightVector< TYPE >::empty(), and set_intersection().

template<class TYPE>
TYPE* LightVector< TYPE >::values  )  const [inline]
 

Access the storage model of this vector directly.

Definition at line 349 of file LightVector.hpp.

References LightVector< TYPE >::m_values.

Referenced by LightVector< TYPE >::create().


Member Data Documentation

template<class TYPE>
int const LightVector< TYPE >::m_capacity [private]
 

Definition at line 386 of file LightVector.hpp.

Referenced by LightVector< TYPE >::begin(), LightVector< TYPE >::capacity(), LightVector< TYPE >::end(), LightVector< TYPE >::push_back(), LightVector< TYPE >::resize(), and LightVector< TYPE >::setEntry().

template<class TYPE>
int& LightVector< TYPE >::m_size [private]
 

Definition at line 384 of file LightVector.hpp.

Referenced by LightVector< TYPE >::back(), LightVector< TYPE >::begin(), LightVector< TYPE >::clear(), LightVector< TYPE >::destroy(), LightVector< TYPE >::end(), LightVector< TYPE >::operator[](), LightVector< TYPE >::pop_back(), LightVector< TYPE >::push_back(), LightVector< TYPE >::resize(), and LightVector< TYPE >::size().

template<class TYPE>
TYPE* const LightVector< TYPE >::m_values [private]
 

Definition at line 383 of file LightVector.hpp.

Referenced by LightVector< TYPE >::back(), LightVector< TYPE >::begin(), LightVector< TYPE >::destroy(), LightVector< TYPE >::end(), LightVector< TYPE >::operator[](), LightVector< TYPE >::push_back(), LightVector< TYPE >::setEntry(), and LightVector< TYPE >::values().


The documentation for this class was generated from the following file:
Generated on Sun Sep 17 17:55:23 2006 for FIM environment by  doxygen 1.4.4