|
PLearn 0.1
|
This allocator solely performs allocation. More...
#include <ArrayAllocatorTrivial.h>

Public Types | |
| typedef ArrayAllocatorTrivial < T, SizeBits > | self |
| typedef T | value_type |
| typedef size_t | size_type |
| typedef ptrdiff_t | difference_type |
| typedef T * | pointer |
| typedef const T * | const_pointer |
| typedef T & | reference |
| typedef const T & | const_reference |
| typedef unsigned | index_base |
| typedef ArrayAllocatorIndex < index_base, SizeBits > | index_type |
Public Member Functions | |
| ArrayAllocatorTrivial (unsigned numberObjects) | |
| pointer | allocate (size_t n) |
| Default copy ctor, dtor, op=. | |
| void | deallocate (pointer p, size_type n) |
| "Deallocate" pointer (no-op) | |
| void | deallocate (index_type) |
| void | resize (size_type newMaxObjs) |
| Change the maximum number of objects. | |
| size_type | max_size () const |
| void | swap (self &) |
| Interchange two allocators. | |
| index_type | toIndex (pointer p, size_type n) |
| Index/pointer conversion. | |
| pointer | toPointer (index_type) |
Private Attributes | |
| vector< T > | arr |
| index_base | free_point |
This allocator solely performs allocation.
Definition at line 60 of file ArrayAllocatorTrivial.h.
| typedef const T* PLearn::ArrayAllocatorTrivial< T, SizeBits >::const_pointer |
Definition at line 69 of file ArrayAllocatorTrivial.h.
| typedef const T& PLearn::ArrayAllocatorTrivial< T, SizeBits >::const_reference |
Definition at line 71 of file ArrayAllocatorTrivial.h.
| typedef ptrdiff_t PLearn::ArrayAllocatorTrivial< T, SizeBits >::difference_type |
Definition at line 66 of file ArrayAllocatorTrivial.h.
| typedef unsigned PLearn::ArrayAllocatorTrivial< T, SizeBits >::index_base |
Definition at line 73 of file ArrayAllocatorTrivial.h.
| typedef ArrayAllocatorIndex<index_base, SizeBits> PLearn::ArrayAllocatorTrivial< T, SizeBits >::index_type |
Definition at line 74 of file ArrayAllocatorTrivial.h.
| typedef T* PLearn::ArrayAllocatorTrivial< T, SizeBits >::pointer |
Definition at line 68 of file ArrayAllocatorTrivial.h.
| typedef T& PLearn::ArrayAllocatorTrivial< T, SizeBits >::reference |
Definition at line 70 of file ArrayAllocatorTrivial.h.
| typedef ArrayAllocatorTrivial<T,SizeBits> PLearn::ArrayAllocatorTrivial< T, SizeBits >::self |
Definition at line 63 of file ArrayAllocatorTrivial.h.
| typedef size_t PLearn::ArrayAllocatorTrivial< T, SizeBits >::size_type |
Definition at line 65 of file ArrayAllocatorTrivial.h.
| typedef T PLearn::ArrayAllocatorTrivial< T, SizeBits >::value_type |
Definition at line 64 of file ArrayAllocatorTrivial.h.
| PLearn::ArrayAllocatorTrivial< T, SizeBits >::ArrayAllocatorTrivial | ( | unsigned | numberObjects | ) |
Definition at line 111 of file ArrayAllocatorTrivial.h.
: arr(numberObjects), free_point(1) {}
| T * PLearn::ArrayAllocatorTrivial< T, SizeBits >::allocate | ( | size_t | n | ) |
Default copy ctor, dtor, op=.
Allocate N objects of type T and return a (memory) pointer to it
Definition at line 125 of file ArrayAllocatorTrivial.h.
{
if(free_point + n > arr.size()) {
PLERROR("Size of memory pool exceeded (%d objects)", arr.size());
return 0;
}
T* p = &arr[free_point];
free_point += n;
return p;
}
| void PLearn::ArrayAllocatorTrivial< T, SizeBits >::deallocate | ( | pointer | p, |
| size_type | n | ||
| ) | [inline] |
| void PLearn::ArrayAllocatorTrivial< T, SizeBits >::deallocate | ( | index_type | ) | [inline] |
Definition at line 85 of file ArrayAllocatorTrivial.h.
{}
| size_type PLearn::ArrayAllocatorTrivial< T, SizeBits >::max_size | ( | ) | const [inline] |
Definition at line 89 of file ArrayAllocatorTrivial.h.
{
return arr.size();
}
| void PLearn::ArrayAllocatorTrivial< T, SizeBits >::resize | ( | size_type | newMaxObjs | ) |
Change the maximum number of objects.
Definition at line 117 of file ArrayAllocatorTrivial.h.
References PLearn::max(), and PLearn::min().
{
arr.resize(newMaxObjs);
free_point = max(1, min(free_point, arr.size()));
}

| void PLearn::ArrayAllocatorTrivial< T, SizeBits >::swap | ( | self & | other | ) |
Interchange two allocators.
Definition at line 138 of file ArrayAllocatorTrivial.h.
References PLearn::swap().
{
arr.swap(other);
swap(free_point, other.free_point);
}

| ArrayAllocatorTrivial< T, SizeBits >::index_type PLearn::ArrayAllocatorTrivial< T, SizeBits >::toIndex | ( | pointer | p, |
| size_type | n | ||
| ) | [inline] |
Index/pointer conversion.
Definition at line 148 of file ArrayAllocatorTrivial.h.
{
if (p)
return index_type(p-&arr[0], n);
else
return index_type(0,0);
}
| ArrayAllocatorTrivial< T, SizeBits >::pointer PLearn::ArrayAllocatorTrivial< T, SizeBits >::toPointer | ( | index_type | i | ) | [inline] |
Definition at line 160 of file ArrayAllocatorTrivial.h.
References PLearn::ArrayAllocatorIndex< IndexBase, SizeBits >::index, and PLearn::ArrayAllocatorIndex< IndexBase, SizeBits >::isNull().

vector<T> PLearn::ArrayAllocatorTrivial< T, SizeBits >::arr [private] |
Definition at line 102 of file ArrayAllocatorTrivial.h.
index_base PLearn::ArrayAllocatorTrivial< T, SizeBits >::free_point [private] |
Definition at line 103 of file ArrayAllocatorTrivial.h.
1.7.4