![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Allocates objects of one given size. More...
#include <agrum/tools/core/fixedAllocator.h>
Public Member Functions | |
const size_t & | objectSize () |
Returns the size of block allocated by this FixedAllocator. More... | |
Constructors / Destructors | |
FixedAllocator (const std::size_t &blockSize, const unsigned char &numBlocks=UCHAR_MAX) | |
Constructor. More... | |
~FixedAllocator () | |
Destructor. More... | |
Allocator / Deallocator | |
void * | allocate () |
Allocates a block. More... | |
void | deallocate (void *pDeallocatedBlock) |
Deallocates a block. More... | |
Classes | |
struct | _Chunk_ |
Allocates objects of one given size. More... | |
Allocates objects of one given size.
Fixed allocator knows how to allocate and deallocate blocks of fixed size but is not limited to a chunck size. Its capacity is limited only by the available memory. To achieve this, FixedAllocator aggregates a vector of Chunk objects. Whenever an allocation request occurs, FixedAllocators looks for a Chunk that can accomodate the request. If all Chunks are filled up, FixedAllocator appends a new Chunk.
Definition at line 58 of file fixedAllocator.h.
|
private |
Vector of Chunk objects.
Definition at line 177 of file fixedAllocator.h.
INLINE gum::FixedAllocator::FixedAllocator | ( | const std::size_t & | blockSize, |
const unsigned char & | numBlocks = UCHAR_MAX |
||
) |
Constructor.
blockSize | is the size of an allocated block. |
numBlocks | is the number of block allocated per chunk numBlock * blockSize is the size that a chunk allocates directly when it is created |
Definition at line 129 of file fixedAllocator_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE gum::FixedAllocator::~FixedAllocator | ( | ) |
Destructor.
Definition at line 141 of file fixedAllocator_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE void * gum::FixedAllocator::allocate | ( | ) |
Allocates a block.
Definition at line 154 of file fixedAllocator_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE void gum::FixedAllocator::deallocate | ( | void * | pDeallocatedBlock | ) |
Deallocates a block.
Definition at line 183 of file fixedAllocator_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inline |
Returns the size of block allocated by this FixedAllocator.
Definition at line 161 of file fixedAllocator.h.
References _blockSize_.
|
private |
Last Chunk used for an allocation.
Definition at line 183 of file fixedAllocator.h.
|
private |
Size of a memory block allocated.
Definition at line 167 of file fixedAllocator.h.
Referenced by objectSize().
|
private |
Definition at line 178 of file fixedAllocator.h.
|
private |
Last Chunk used for a deallocation.
Definition at line 188 of file fixedAllocator.h.
|
private |
The maximum number of blocks a chunk can allocate.
Definition at line 172 of file fixedAllocator.h.