|
PLearn 0.1
|
#include <SmallVector.h>

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_type & | operator= (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) |
| Stack operations. | |
| void | pop_back () |
| remove last element | |
| size_type | size () const |
| (list operations are NOT provided at the moment) | |
| 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 | |
| static void | allocator (alloc_type *the_alloc) |
| Set here the allocator you want (we capture the object) | |
| static alloc_type & | allocator () |
Private Attributes | |
| alloc_type::index_type | i |
| index of vector in memory | |
Static Private Attributes | |
| static alloc_type * | alloc |
| underlying 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.
| typedef Allocator PLearn::SmallVector< T, SizeBits, Allocator >::alloc_type |
Definition at line 67 of file SmallVector.h.
| typedef const T* PLearn::SmallVector< T, SizeBits, Allocator >::const_iterator |
Definition at line 74 of file SmallVector.h.
| typedef const T* PLearn::SmallVector< T, SizeBits, Allocator >::const_pointer |
Definition at line 77 of file SmallVector.h.
| typedef const T& PLearn::SmallVector< T, SizeBits, Allocator >::const_reference |
Definition at line 79 of file SmallVector.h.
| typedef ptrdiff_t PLearn::SmallVector< T, SizeBits, Allocator >::difference_type |
Definition at line 71 of file SmallVector.h.
| typedef T* PLearn::SmallVector< T, SizeBits, Allocator >::iterator |
Definition at line 73 of file SmallVector.h.
| typedef T* PLearn::SmallVector< T, SizeBits, Allocator >::pointer |
Definition at line 76 of file SmallVector.h.
| typedef T& PLearn::SmallVector< T, SizeBits, Allocator >::reference |
Definition at line 78 of file SmallVector.h.
| typedef SmallVector<T,SizeBits> PLearn::SmallVector< T, SizeBits, Allocator >::self_type |
Typedefs.
Definition at line 66 of file SmallVector.h.
| typedef size_t PLearn::SmallVector< T, SizeBits, Allocator >::size_type |
Definition at line 70 of file SmallVector.h.
| typedef T PLearn::SmallVector< T, SizeBits, Allocator >::value_type |
Definition at line 69 of file SmallVector.h.
| PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector | ( | ) | [inline] |
| PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector | ( | size_type | n, |
| const T & | val = T() |
||
| ) | [inline] |
Definition at line 356 of file SmallVector.h.
References PLearn::SmallVector< T, SizeBits, Allocator >::assign().

| PLearn::SmallVector< T, SizeBits, Allocator >::~SmallVector | ( | ) |
| PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector | ( | const self_type & | other | ) |
Definition at line 364 of file SmallVector.h.
References PLearn::SmallVector< T, SizeBits, Allocator >::assign(), PLearn::SmallVector< T, SizeBits, Allocator >::begin(), and PLearn::SmallVector< T, SizeBits, Allocator >::end().

| PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector | ( | In | first, |
| In | last | ||
| ) | [inline] |
Construct/Copy from Input iterator.
Definition at line 112 of file SmallVector.h.
| static void PLearn::SmallVector< T, SizeBits, Allocator >::allocator | ( | alloc_type * | the_alloc | ) | [inline, static] |
| static alloc_type& PLearn::SmallVector< T, SizeBits, Allocator >::allocator | ( | ) | [inline, static] |
Definition at line 157 of file SmallVector.h.
{
return *alloc;
}
| 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.
Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector().

| void PLearn::SmallVector< T, SizeBits, Allocator >::assign | ( | size_type | n, |
| const T & | val | ||
| ) | [inline] |
| SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::at | ( | size_type | n | ) | const |
| SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::at | ( | size_type | n | ) |
| SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::back | ( | ) | [inline] |
| SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::back | ( | ) | const [inline] |
| 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 i.
| 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 i.
Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::operator=(), PLearn::operator==(), and PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector().

| bool PLearn::SmallVector< T, SizeBits, Allocator >::empty | ( | ) | const [inline] |
Definition at line 138 of file SmallVector.h.
{
return size() == 0;
}
| SmallVector< T, SizeBits, Allocator >::const_iterator PLearn::SmallVector< T, SizeBits, Allocator >::end | ( | ) | const [inline] |
Definition at line 233 of file SmallVector.h.
| SmallVector< T, SizeBits, Allocator >::iterator PLearn::SmallVector< T, SizeBits, Allocator >::end | ( | ) | [inline] |
Definition at line 225 of file SmallVector.h.
Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::operator=(), PLearn::operator==(), and PLearn::SmallVector< T, SizeBits, Allocator >::SmallVector().

| SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::front | ( | ) | [inline] |
| SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::front | ( | ) | const [inline] |
| size_type PLearn::SmallVector< T, SizeBits, Allocator >::max_size | ( | ) | [inline] |
Definition at line 141 of file SmallVector.h.
{
typename alloc_type::index_type dummy(unsigned(-1), unsigned(-1));
return dummy.size;
}
| SmallVector< T, SizeBits, Allocator >::self_type & PLearn::SmallVector< T, SizeBits, Allocator >::operator= | ( | const self_type & | other | ) |
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().
{
if (size() != other.size()) {
self_type tmp(other);
swap(tmp);
}
else {
assign(other.begin(), other.end());
}
return *this;
}

| SmallVector< T, SizeBits, Allocator >::reference PLearn::SmallVector< T, SizeBits, Allocator >::operator[] | ( | size_type | n | ) | [inline] |
| SmallVector< T, SizeBits, Allocator >::const_reference PLearn::SmallVector< T, SizeBits, Allocator >::operator[] | ( | size_type | n | ) | const [inline] |
| void PLearn::SmallVector< T, SizeBits, Allocator >::pop_back | ( | ) |
| void PLearn::SmallVector< T, SizeBits, Allocator >::push_back | ( | const T & | x | ) |
| void PLearn::SmallVector< T, SizeBits, Allocator >::reserve | ( | size_type | n | ) |
| 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 i, PLearn::max(), PLearn::min(), and PLERROR.
{
if (sz > max_size())
PLERROR("%s: out-of-range.",typeid(*this).name());
pointer newdata = allocator().allocate(sz);
typename alloc_type::index_type newi = allocator().toIndex(newdata, sz);
pointer olddata = allocator().toPointer(i);
size_type n = std::min(int(sz), int(i.size));
while (n--)
*newdata++ = *olddata++;
n = std::max(0, int(sz) - int(i.size));
while (n--)
*newdata++ = val;
allocator().deallocate(i);
i = newi;
}

| SmallVector< T, SizeBits, Allocator >::size_type PLearn::SmallVector< T, SizeBits, Allocator >::size | ( | ) | const |
(list operations are NOT provided at the moment)
Size and capacity operations number of elements
Definition at line 420 of file SmallVector.h.
References i.
Referenced by PLearn::SmallVector< T, SizeBits, Allocator >::operator=().

| void PLearn::SmallVector< T, SizeBits, Allocator >::swap | ( | SmallVector< T, SizeBits, Allocator > & | other | ) |
Other functions.
Definition at line 469 of file SmallVector.h.
References PLearn::SmallVector< T, SizeBits, Allocator >::i, i, and PLearn::swap().

Allocator * PLearn::SmallVector< T, SizeBits, Allocator >::alloc [static, private] |
underlying allocator
Definition at line 162 of file SmallVector.h.
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 >::swap().
1.7.4