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

PLearn::TinyVector< T, N, TTrait > Class Template Reference

#include <TinyVector.h>

Inheritance diagram for PLearn::TinyVector< T, N, TTrait >:

Inheritance graph
[legend]
Collaboration diagram for PLearn::TinyVector< T, N, TTrait >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef T value_type
 Typedefs.

typedef size_t size_type
typedef ptrdiff_t difference_type
typedef T * iterator
typedef const T * const_iterator
typedef T * pointer
typedef const T * const_pointer
typedef T & reference
typedef const T & const_reference

Public Member Functions

iterator begin ()
 Iterators.

const_iterator begin () const
iterator end ()
const_iterator end () const
reference operator[] (size_type n)
 Unchecked element access.

const_reference operator[] (size_type n) const
reference at (size_type n)
 Checked element access.

const_reference at (size_type n) const
reference front ()
 first element

const_reference front () const
reference back ()
 last element

const_reference back () const
 TinyVector ()
 Constructors, etc.

 TinyVector (size_type n, const T &val=T())
template<class In>  TinyVector (In first, In last)
 Use default copy constructor, destructor, assignment operator Construct/Copy from Input iterator.

template<class In> void assign (In first, In last)
void assign (size_type n, const T &val)
 n copies of val

void push_back (const T &x)
 add to end

void pop_back ()
 remove last element

size_type size () const
 number of elements

bool empty () const
size_type max_size ()
void resize (size_type sz, const T &val=T())
 added elts init by val

void reserve (size_type n)
 make room for total of n elts

void swap (TinyVector &)
 Other functions.


Private Attributes

arr [N]

Detailed Description

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
class PLearn::TinyVector< T, N, TTrait >

A tiny vector tries to mimic (a small subset of) the interface of a built-in standard vector<>, but it has an additional restriction: it can hold a compile-time maximum number of elements. In exchange for this restriction, it allocates the elements of the vector within the class, which completely eliminates the need for dynamic allocation. In addition, the size of the vector is not stored explicitly, but rather determined from the number of "missing values". What exactly should be considered a missing value differs for each type T, which is why a TinyVectorTrait::Missing is defined for useful types. You can also define one yourself.

Definition at line 69 of file TinyVector.h.


Member Typedef Documentation

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef const T* PLearn::TinyVector< T, N, TTrait >::const_iterator
 

Definition at line 78 of file TinyVector.h.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef const T* PLearn::TinyVector< T, N, TTrait >::const_pointer
 

Definition at line 81 of file TinyVector.h.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef const T& PLearn::TinyVector< T, N, TTrait >::const_reference
 

Definition at line 83 of file TinyVector.h.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef ptrdiff_t PLearn::TinyVector< T, N, TTrait >::difference_type
 

Definition at line 75 of file TinyVector.h.

Referenced by PLearn::TinyVector< T, N, TTrait >::size().

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef T* PLearn::TinyVector< T, N, TTrait >::iterator
 

Definition at line 77 of file TinyVector.h.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef T* PLearn::TinyVector< T, N, TTrait >::pointer
 

Definition at line 80 of file TinyVector.h.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef T& PLearn::TinyVector< T, N, TTrait >::reference
 

Definition at line 82 of file TinyVector.h.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef size_t PLearn::TinyVector< T, N, TTrait >::size_type
 

Definition at line 74 of file TinyVector.h.

Referenced by PLearn::TinyVector< T, N, TTrait >::assign(), PLearn::TinyVector< T, N, TTrait >::pop_back(), PLearn::TinyVector< T, N, TTrait >::push_back(), PLearn::TinyVector< T, N, TTrait >::resize(), PLearn::TinyVector< T, N, TTrait >::swap(), and PLearn::TinyVector< T, N, TTrait >::TinyVector().

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
typedef T PLearn::TinyVector< T, N, TTrait >::value_type
 

Typedefs.

Definition at line 73 of file TinyVector.h.


Constructor & Destructor Documentation

template<class T, unsigned N, class TTrait>
PLearn::TinyVector< T, N, TTrait >::TinyVector  )  [inline]
 

Constructors, etc.

Definition at line 358 of file TinyVector.h.

template<class T, unsigned N, class TTrait>
PLearn::TinyVector< T, N, TTrait >::TinyVector size_type  n,
const T &  val = T()
[inline, explicit]
 

Definition at line 365 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLearn::TinyVector< T, N, TTrait >::size_type, and val.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
template<class In>
PLearn::TinyVector< T, N, TTrait >::TinyVector In  first,
In  last
 

Use default copy constructor, destructor, assignment operator Construct/Copy from Input iterator.


Member Function Documentation

template<class T, unsigned N, class TTrait>
void PLearn::TinyVector< T, N, TTrait >::assign size_type  n,
const T &  val
[inline]
 

n copies of val

Definition at line 347 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, resize(), PLearn::TinyVector< T, N, TTrait >::size_type, and val.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
template<class In>
void PLearn::TinyVector< T, N, TTrait >::assign In  first,
In  last
[inline]
 

could not define it out-of-line; bug in gcc?

Definition at line 117 of file TinyVector.h.

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::const_reference PLearn::TinyVector< T, N, TTrait >::at size_type  n  )  const
 

n cannot be less than zero, because size_type is usually unsigned

Definition at line 294 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, and PLearn::TinyVector< T, N, TTrait >::size().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::reference PLearn::TinyVector< T, N, TTrait >::at size_type  n  ) 
 

Checked element access.

n cannot be less than zero, because size_type is usually unsigned

Definition at line 283 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, and PLearn::TinyVector< T, N, TTrait >::size().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::const_reference PLearn::TinyVector< T, N, TTrait >::back  )  const [inline]
 

Definition at line 335 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::empty(), PLearn::TinyVector< T, N, TTrait >::end(), and PLERROR.

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::reference PLearn::TinyVector< T, N, TTrait >::back  )  [inline]
 

last element

Definition at line 325 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::empty(), PLearn::TinyVector< T, N, TTrait >::end(), and PLERROR.

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::const_iterator PLearn::TinyVector< T, N, TTrait >::begin  )  const [inline]
 

This is always correct, even for zero-size vectors

Definition at line 236 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr.

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::iterator PLearn::TinyVector< T, N, TTrait >::begin  )  [inline]
 

Iterators.

This is always correct, even for zero-size vectors

Definition at line 228 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr.

Referenced by PLearn::operator==().

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
bool PLearn::TinyVector< T, N, TTrait >::empty  )  const [inline]
 

Definition at line 137 of file TinyVector.h.

Referenced by PLearn::TinyVector< T, N, TTrait >::back(), PLearn::TTensor< T >::DEPRECATEDsubTensor(), PLearn::TinyVector< T, N, TTrait >::front(), and PLearn::TTensor< T >::subTensor().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::const_iterator PLearn::TinyVector< T, N, TTrait >::end  )  const [inline]
 

Definition at line 251 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, and PLearn::TinyVector< T, N, TTrait >::size().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::iterator PLearn::TinyVector< T, N, TTrait >::end  )  [inline]
 

Definition at line 244 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, and PLearn::TinyVector< T, N, TTrait >::size().

Referenced by PLearn::TinyVector< T, N, TTrait >::back(), and PLearn::operator==().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::const_reference PLearn::TinyVector< T, N, TTrait >::front  )  const [inline]
 

Definition at line 315 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLearn::TinyVector< T, N, TTrait >::empty(), and PLERROR.

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::reference PLearn::TinyVector< T, N, TTrait >::front  )  [inline]
 

first element

Definition at line 305 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLearn::TinyVector< T, N, TTrait >::empty(), and PLERROR.

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
size_type PLearn::TinyVector< T, N, TTrait >::max_size  )  [inline]
 

Definition at line 140 of file TinyVector.h.

Referenced by PLearn::TinyVector< T, N, TTrait >::reserve(), and PLearn::TinyVector< T, N, TTrait >::resize().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::const_reference PLearn::TinyVector< T, N, TTrait >::operator[] size_type  n  )  const [inline]
 

Definition at line 272 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, and PLearn::TinyVector< T, N, TTrait >::size().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::reference PLearn::TinyVector< T, N, TTrait >::operator[] size_type  n  )  [inline]
 

Unchecked element access.

Definition at line 261 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, and PLearn::TinyVector< T, N, TTrait >::size().

template<class T, unsigned N, class TTrait>
void PLearn::TinyVector< T, N, TTrait >::pop_back  ) 
 

remove last element

Definition at line 387 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, PLearn::TinyVector< T, N, TTrait >::size(), and PLearn::TinyVector< T, N, TTrait >::size_type.

template<class T, unsigned N, class TTrait>
void PLearn::TinyVector< T, N, TTrait >::push_back const T &  x  ) 
 

add to end

Definition at line 377 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLERROR, PLearn::TinyVector< T, N, TTrait >::size(), PLearn::TinyVector< T, N, TTrait >::size_type, and x.

Referenced by PLearn::TTensor< T >::DEPRECATEDsubTensor(), PLearn::TTensor< T >::operator[](), PLearn::TTensor< T >::selectDimensions(), and PLearn::TTensor< T >::subTensor().

template<class T, unsigned N, class TTrait>
void PLearn::TinyVector< T, N, TTrait >::reserve size_type  n  ) 
 

make room for total of n elts

Definition at line 424 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::max_size(), and PLERROR.

template<class T, unsigned N, class TTrait>
void PLearn::TinyVector< T, N, TTrait >::resize size_type  sz,
const T &  val = T()
 

added elts init by val

Definition at line 411 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLearn::TinyVector< T, N, TTrait >::max_size(), PLERROR, PLearn::TinyVector< T, N, TTrait >::size(), PLearn::TinyVector< T, N, TTrait >::size_type, and val.

Referenced by PLearn::TTensor< T >::lastElementPos(), PLearn::TTensor< T >::resize(), and PLearn::TTensorElementIterator< T >::TTensorElementIterator().

template<class T, unsigned N, class TTrait>
TinyVector< T, N, TTrait >::size_type PLearn::TinyVector< T, N, TTrait >::size  )  const
 

number of elements

Definition at line 401 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, and PLearn::TinyVector< T, N, TTrait >::difference_type.

Referenced by PLearn::TinyVector< T, N, TTrait >::at(), PLearn::TinyVector< int, 7 >::empty(), PLearn::TinyVector< T, N, TTrait >::end(), PLearn::TTensor< T >::ndims(), PLearn::TinyVector< T, N, TTrait >::operator[](), PLearn::TinyVector< T, N, TTrait >::pop_back(), PLearn::TinyVector< T, N, TTrait >::push_back(), PLearn::TinyVector< T, N, TTrait >::resize(), and PLearn::TTensor< T >::selectDimensions().

template<class T, unsigned N, class TTrait>
void PLearn::TinyVector< T, N, TTrait >::swap TinyVector< T, N, TTrait > &  other  ) 
 

Other functions.

otherwise uses Koenig lookup

< if necessary for swap;

Definition at line 435 of file TinyVector.h.

References PLearn::TinyVector< T, N, TTrait >::arr, PLearn::TinyVector< T, N, TTrait >::size_type, and PLearn::swap().


Member Data Documentation

template<class T, unsigned N, class TTrait = TinyVectorTrait<T>>
T PLearn::TinyVector< T, N, TTrait >::arr[N] [private]
 

Definition at line 151 of file TinyVector.h.

Referenced by PLearn::TinyVector< T, N, TTrait >::assign(), PLearn::TinyVector< T, N, TTrait >::at(), PLearn::TinyVector< T, N, TTrait >::begin(), PLearn::TinyVector< T, N, TTrait >::end(), PLearn::TinyVector< T, N, TTrait >::front(), PLearn::TinyVector< T, N, TTrait >::operator[](), PLearn::TinyVector< T, N, TTrait >::pop_back(), PLearn::TinyVector< T, N, TTrait >::push_back(), PLearn::TinyVector< T, N, TTrait >::resize(), PLearn::TinyVector< T, N, TTrait >::size(), PLearn::TinyVector< T, N, TTrait >::swap(), and PLearn::TinyVector< T, N, TTrait >::TinyVector().


The documentation for this class was generated from the following file:
Generated on Tue Aug 17 16:22:45 2004 for PLearn by doxygen 1.3.7