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

PLearn::SmallVector< T, SizeBits, Allocator > Class Template Reference

#include <SmallVector.h>

Collaboration diagram for PLearn::SmallVector< T, SizeBits, Allocator >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef SmallVector< T, SizeBits > self_type
 Typedefs.

typedef Allocator alloc_type
typedef T value_type
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
 SmallVector ()
 Constructors, etc.

 SmallVector (size_type n, const T &val=T())
 ~SmallVector ()
 SmallVector (const self_type &)
self_typeoperator= (const self_type &)
template<class In>  SmallVector (In first, In last)
 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 (SmallVector &)
 Other functions.


Static Public Member Functions

void allocator (alloc_type *the_alloc)
 Set here the allocator you want (we capture the object).

alloc_typeallocator ()

Private Attributes

alloc_type::index_type i
 index of vector in memory


Static Private Attributes

alloc_typealloc
 underlying allocator


Detailed Description

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
class PLearn::SmallVector< T, SizeBits, Allocator >

A small vector is designed to have a predetermined maximum fixed size, specified as a template arguments (with SizeBits; e.g. SizeBits=8 for maximum size=256). It is built over an ArrayAllocator. These vectors trade representational efficiency for resizing performance (i.e. they always require a copy to resize).

Definition at line 62 of file SmallVector.h.


Member Typedef Documentation

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef Allocator PLearn::SmallVector< T, SizeBits, Allocator >::alloc_type
 

Definition at line 67 of file SmallVector.h.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::allocator().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef const T* PLearn::SmallVector< T, SizeBits, Allocator >::const_iterator
 

Definition at line 74 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef const T* PLearn::SmallVector< T, SizeBits, Allocator >::const_pointer
 

Definition at line 77 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef const T& PLearn::SmallVector< T, SizeBits, Allocator >::const_reference
 

Definition at line 79 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef ptrdiff_t PLearn::SmallVector< T, SizeBits, Allocator >::difference_type
 

Definition at line 71 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef T* PLearn::SmallVector< T, SizeBits, Allocator >::iterator
 

Definition at line 73 of file SmallVector.h.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::assign().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef T* PLearn::SmallVector< T, SizeBits, Allocator >::pointer
 

Definition at line 76 of file SmallVector.h.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::resize().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef T& PLearn::SmallVector< T, SizeBits, Allocator >::reference
 

Definition at line 78 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef SmallVector<T,SizeBits> PLearn::SmallVector< T, SizeBits, Allocator >::self_type
 

Typedefs.

Definition at line 66 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef size_t PLearn::SmallVector< T, SizeBits, Allocator >::size_type
 

Definition at line 70 of file SmallVector.h.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::assign(), PLearn::SmallVector< T, SizeBits, Allocator >::max_size(), PLearn::SmallVector< T, SizeBits, Allocator >::pop_back(), PLearn::SmallVector< T, SizeBits, Allocator >::push_back(), and PLearn::SmallVector< T, SizeBits, Allocator >::resize().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
typedef T PLearn::SmallVector< T, SizeBits, Allocator >::value_type
 

Definition at line 69 of file SmallVector.h.


Constructor & Destructor Documentation

template<class T, unsigned SizeBits, class Allocator>
PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector  )  [inline]
 

Constructors, etc.

Definition at line 350 of file SmallVector.h.

template<class T, unsigned SizeBits, class Allocator>
PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector size_type  n,
const T &  val = T()
[inline]
 

Definition at line 356 of file SmallVector.h.

References val.

template<class T, unsigned SizeBits, class Allocator>
PLearn::SmallVector< T, SizeBits, Allocator >::~SmallVector  ) 
 

Definition at line 372 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::allocator(), and PLearn::SmallVector< T, SizeBits, Allocator >::i.

template<class T, unsigned SizeBits, class Allocator>
PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector const self_type  ) 
 

Definition at line 364 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), and PLearn::SmallVector< T, SizeBits, Allocator >::end().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
template<class In>
PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector In  first,
In  last
[inline]
 

Construct/Copy from Input iterator.

Definition at line 112 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::assign().


Member Function Documentation

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
alloc_type& PLearn::SmallVector< T, SizeBits, Allocator >::allocator  )  [inline, static]
 

Definition at line 157 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::alloc, and PLearn::SmallVector< T, SizeBits, Allocator >::alloc_type.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLearn::SmallVector< T, SizeBits, Allocator >::resize(), and PLearn::SmallVector< T, SizeBits, Allocator >::~SmallVector().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
void PLearn::SmallVector< T, SizeBits, Allocator >::allocator alloc_type the_alloc  )  [inline, static]
 

Set here the allocator you want (we capture the object).

Definition at line 153 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::alloc.

template<class T, unsigned SizeBits, class Allocator>
void PLearn::SmallVector< T, SizeBits, Allocator >::assign size_type  n,
const T &  val
[inline]
 

n copies of val

Definition at line 338 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::i, PLearn::SmallVector< T, SizeBits, Allocator >::max_size(), PLERROR, resize(), PLearn::SmallVector< T, SizeBits, Allocator >::size_type, and val.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
template<class In>
void PLearn::SmallVector< T, SizeBits, Allocator >::assign In  first,
In  last
[inline]
 

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

Definition at line 117 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::assign(), PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLearn::SmallVector< T, SizeBits, Allocator >::iterator, and resize().

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::assign(), and PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::at size_type  n  )  const
 

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

Definition at line 280 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLERROR, and PLearn::SmallVector< T, SizeBits, Allocator >::size().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::at size_type  n  ) 
 

Checked element access.

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

Definition at line 268 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLERROR, and PLearn::SmallVector< T, SizeBits, Allocator >::size().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::back  )  const [inline]
 

Definition at line 325 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::empty(), PLearn::SmallVector< T, SizeBits, Allocator >::end(), and PLERROR.

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::back  )  [inline]
 

last element

Definition at line 314 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::empty(), PLearn::SmallVector< T, SizeBits, Allocator >::end(), and PLERROR.

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::const_iterator PLearn::SmallVector< T, SizeBits, Allocator >::begin  )  const [inline]
 

This is always correct, even for zero-size vectors

Definition at line 216 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::allocator(), and PLearn::SmallVector< T, SizeBits, Allocator >::i.

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::iterator PLearn::SmallVector< T, SizeBits, Allocator >::begin  )  [inline]
 

Iterators.

This is always correct, even for zero-size vectors

Definition at line 207 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::allocator(), and PLearn::SmallVector< T, SizeBits, Allocator >::i.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::assign(), PLearn::SmallVector< T, SizeBits, Allocator >::at(), PLearn::SmallVector< T, SizeBits, Allocator >::end(), PLearn::SmallVector< T, SizeBits, Allocator >::front(), PLearn::SmallVector< T, SizeBits, Allocator >::operator=(), PLearn::operator==(), PLearn::SmallVector< T, SizeBits, Allocator >::operator[](), and PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
bool PLearn::SmallVector< T, SizeBits, Allocator >::empty  )  const [inline]
 

Definition at line 138 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::size().

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::back(), and PLearn::SmallVector< T, SizeBits, Allocator >::front().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::const_iterator PLearn::SmallVector< T, SizeBits, Allocator >::end  )  const [inline]
 

Definition at line 233 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), and PLearn::SmallVector< T, SizeBits, Allocator >::size().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::iterator PLearn::SmallVector< T, SizeBits, Allocator >::end  )  [inline]
 

Definition at line 225 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), and PLearn::SmallVector< T, SizeBits, Allocator >::size().

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::back(), PLearn::SmallVector< T, SizeBits, Allocator >::operator=(), PLearn::operator==(), and PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::front  )  const [inline]
 

Definition at line 303 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLearn::SmallVector< T, SizeBits, Allocator >::empty(), and PLERROR.

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::front  )  [inline]
 

first element

Definition at line 292 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLearn::SmallVector< T, SizeBits, Allocator >::empty(), and PLERROR.

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
size_type PLearn::SmallVector< T, SizeBits, Allocator >::max_size  )  [inline]
 

Definition at line 141 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::size_type.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::assign(), PLearn::SmallVector< T, SizeBits, Allocator >::reserve(), and PLearn::SmallVector< T, SizeBits, Allocator >::resize().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::self_type & PLearn::SmallVector< T, SizeBits, Allocator >::operator= const self_type  ) 
 

Definition at line 380 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLearn::SmallVector< T, SizeBits, Allocator >::end(), PLearn::SmallVector< T, SizeBits, Allocator >::size(), and PLearn::swap().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::operator[] size_type  n  )  const [inline]
 

Definition at line 256 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLERROR, and PLearn::SmallVector< T, SizeBits, Allocator >::size().

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::operator[] size_type  n  )  [inline]
 

Unchecked element access.

Definition at line 244 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLERROR, and PLearn::SmallVector< T, SizeBits, Allocator >::size().

template<class T, unsigned SizeBits, class Allocator>
void PLearn::SmallVector< T, SizeBits, Allocator >::pop_back  ) 
 

remove last element

Definition at line 406 of file SmallVector.h.

References PLERROR, resize(), PLearn::SmallVector< T, SizeBits, Allocator >::size(), and PLearn::SmallVector< T, SizeBits, Allocator >::size_type.

template<class T, unsigned SizeBits, class Allocator>
void PLearn::SmallVector< T, SizeBits, Allocator >::push_back const T &  x  ) 
 

add to end

Definition at line 397 of file SmallVector.h.

References resize(), PLearn::SmallVector< T, SizeBits, Allocator >::size(), PLearn::SmallVector< T, SizeBits, Allocator >::size_type, and x.

template<class T, unsigned SizeBits, class Allocator>
void PLearn::SmallVector< T, SizeBits, Allocator >::reserve size_type  n  ) 
 

make room for total of n elts

Definition at line 457 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::max_size(), and PLERROR.

template<class T, unsigned SizeBits, class Allocator>
void PLearn::SmallVector< T, SizeBits, Allocator >::resize size_type  sz,
const T &  val = T()
 

added elts init by val

Copy old data on new data

Initialize remaining of new data

make new size effective

Definition at line 430 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::allocator(), PLearn::SmallVector< T, SizeBits, Allocator >::i, PLearn::SmallVector< T, SizeBits, Allocator >::max_size(), PLERROR, PLearn::SmallVector< T, SizeBits, Allocator >::pointer, PLearn::SmallVector< T, SizeBits, Allocator >::size_type, and val.

template<class T, unsigned SizeBits, class Allocator>
SmallVector< T, SizeBits, Allocator >::size_type PLearn::SmallVector< T, SizeBits, Allocator >::size  )  const
 

number of elements

Definition at line 420 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::i.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::at(), PLearn::SmallVector< T, SizeBits, Allocator >::empty(), PLearn::SmallVector< T, SizeBits, Allocator >::end(), PLearn::SmallVector< T, SizeBits, Allocator >::operator=(), PLearn::SmallVector< T, SizeBits, Allocator >::operator[](), PLearn::SmallVector< T, SizeBits, Allocator >::pop_back(), and PLearn::SmallVector< T, SizeBits, Allocator >::push_back().

template<class T, unsigned SizeBits, class Allocator>
void PLearn::SmallVector< T, SizeBits, Allocator >::swap SmallVector< T, SizeBits, Allocator > &   ) 
 

Other functions.

Definition at line 469 of file SmallVector.h.

References PLearn::SmallVector< T, SizeBits, Allocator >::i.


Member Data Documentation

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
Allocator * PLearn::SmallVector< T, SizeBits, Allocator >::alloc [static, private]
 

underlying allocator

Definition at line 198 of file SmallVector.h.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::allocator().

template<class T, unsigned SizeBits, class Allocator = ArrayAllocatorTrivial<T,SizeBits>>
alloc_type::index_type PLearn::SmallVector< T, SizeBits, Allocator >::i [private]
 

index of vector in memory

Definition at line 163 of file SmallVector.h.

Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::assign(), PLearn::SmallVector< T, SizeBits, Allocator >::begin(), PLearn::SmallVector< T, SizeBits, Allocator >::resize(), PLearn::SmallVector< T, SizeBits, Allocator >::size(), PLearn::SmallVector< T, SizeBits, Allocator >::swap(), and PLearn::SmallVector< T, SizeBits, Allocator >::~SmallVector().


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