SmallVector

Defines a vector template. This class template was designed as a cheap substitute to vector<> class template. The SmallVector class has a smaller executable size, takes up less memory, is simpler and should usually prove to be faster than the larger, more verbose vector<> class. template< class T, class Alloc = ShortVectorBase>

[ GAMB | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

AUTHORS
CHANGES LOG
GOALS
USAGE

Class Summary

class SmallVector :
public ShortVectorBase

{
public:
typedef T value_type;
typedef typename Alloc::size_type size_type;
typedef T* iterator;
typedef const T* const_iterator;
typedef T& reference;
typedef const T& const_reference;
explicit SmallVector(unsigned short defAlloc );
explicit SmallVector(unsigned short Objects, unsigned short defAlloc );
SmallVector(const SmallVector< T, Alloc>& a);
~SmallVector();
void push_back(const T& elem);
reference operator[](unsigned short index);
const_reference operator[](unsigned short index) const;
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
protected:
}; // SmallVector

Back to the top of SmallVector


AUTHORS

Meir Fuchs. (meirfux@math.tau.ac.il)

Copyright: SAMBA group, Tel-Aviv Univ. Israel, 1997.

Back to the top of SmallVector


CHANGES LOG

Back to the top of SmallVector


GOALS

Defines a cheap vector<> template class. The size of the vector may be limited, no insertion methods only push_back, simple deletion methods. There is no allocator class involved and the iterators are defined as simple pointers. This results in smaller excutable footprint, some reduction in memory usage and usually faster code.

Back to the top of SmallVector


USAGE

Usage of the SmallVector class template is similar to that of the vector class template.

Note that one may supply a different base class to the SmallVector class. This immediately raises two possiblilities:
a. Change size and space to integers and thereby allow virtually unlimited vector length.
b. Redefine the incrAllocSpace function which calculates the amount of space to be allocated when the allocated space overflows due to a push_back operation.

The class is not truly STL compliant though feeding this container into some of the STL algoritms might actually work.

Back to the top of SmallVector


typedef T value_type;

STL compliant typedef.

  typedef T value_type;

Back to the top of SmallVector


typedef typename Alloc::size_type size_type;

STL compliant typedef.

  typedef typename Alloc::size_type size_type;

Back to the top of SmallVector


typedef T* iterator;

STL compliant typedef.

  typedef T* iterator;

Back to the top of SmallVector


typedef const T* const_iterator;

STL compliant typedef.

  typedef const T* const_iterator;

Back to the top of SmallVector


typedef T& reference;

STL compliant typedef.

  typedef T& reference;

Back to the top of SmallVector


typedef const T& const_reference;

STL compliant typedef.

  typedef const T& const_reference;

Back to the top of SmallVector


explicit SmallVector(unsigned short defAlloc );

Constructor receives initial space to allocate. Default is 3.

  explicit SmallVector(unsigned short defAlloc=3);

Back to the top of SmallVector


explicit SmallVector(unsigned short Objects, unsigned short defAlloc );

Constructor receives initial number of objects in create in the // vector and initial space to allocate. // If space is too small to fit objects - SmallVector will allocate more! // Please VERY be carefull the first object are NOT initiated they are // meaningless objects

  explicit SmallVector(unsigned short Objects, unsigned short defAlloc=3);

Back to the top of SmallVector


SmallVector(const SmallVector< T, Alloc>& a);

Copy constructor

  SmallVector(const SmallVector< T, Alloc>& a);

Back to the top of SmallVector


~SmallVector();

Destructor. Deletes vector data.

  ~SmallVector();

Back to the top of SmallVector


void push_back(const T& elem);

Adds an item at the end of the array. Allocates more space if needed.

  void push_back(const T& elem);

Back to the top of SmallVector


reference operator[](unsigned short index);

Returns reference to indexed element of the vector.

  reference operator[](unsigned short index);

Back to the top of SmallVector


const_reference operator[](unsigned short index) const;

Returns a const reference to indexed element of the vector.

  const_reference operator[](unsigned short index) const;

Back to the top of SmallVector


iterator begin();

Returns a pointer to the vector's head.

  iterator begin();

Back to the top of SmallVector


const_iterator begin() const;

Returns a pointer to the vector's head.

  const_iterator begin() const;

Back to the top of SmallVector


iterator end();

Returns a pointer to the vector's end. The end is past the last element of the vector.

  iterator end();

Back to the top of SmallVector


const_iterator end() const;

Returns a pointer to the vector's end. The end is past the last element of the vector.

  const_iterator end() const;

Back to the top of SmallVector


All Members

public:
typedef T value_type;
typedef typename Alloc::size_type size_type;
typedef T* iterator;
typedef const T* const_iterator;
typedef T& reference;
typedef const T& const_reference;
explicit SmallVector(unsigned short defAlloc );
explicit SmallVector(unsigned short Objects, unsigned short defAlloc );
void push_back(const T& elem);
reference operator[](unsigned short index);
const_reference operator[](unsigned short index) const;
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
protected:

Back to the top of SmallVector


Ancestors

Inheritance chain for SmallVector:

Back to the top of SmallVector


Descendants

Class is not inherited by any others.

Back to the top of SmallVector


Generated from source by the Cocoon utilities on Sun Nov 15 13:35:26 2009 .

Report problems to jkotula@unimax.com