Use this class to manage a finite amount of memory. The idea is to have an array which stores objects and a vector which has pointers to said objects in the array. The array is sparsely populated using optionals.
More...
#include <DescriptorIndexAllocator.h>
|
| | DescriptorIndexAllocator ()=delete |
| | DescriptorIndexAllocator (int descriptorCount) |
| uint32_t | allocate () |
| | Get an index where there is no data in the array.
|
| void | free (uint32_t index) |
| | Frees a cell in the array where the memory is not used anymore.
|
| const std::vector< uint32_t > & | getUsedIndices () const |
| | Gets the indices of all allocated fields in the array.
|
| void | reset (int newSize) |
| | Resets all values in the buffers and allocates with new size.
|
| size_t | getCapacity () const |
Use this class to manage a finite amount of memory. The idea is to have an array which stores objects and a vector which has pointers to said objects in the array. The array is sparsely populated using optionals.
Definition at line 12 of file DescriptorIndexAllocator.h.
◆ DescriptorIndexAllocator() [1/2]
| Engine::Core::DescriptorIndexAllocator::DescriptorIndexAllocator |
( |
| ) |
|
|
delete |
◆ DescriptorIndexAllocator() [2/2]
| Engine::Core::DescriptorIndexAllocator::DescriptorIndexAllocator |
( |
int | descriptorCount | ) |
|
|
explicit |
◆ allocate()
| uint32_t Engine::Core::DescriptorIndexAllocator::allocate |
( |
| ) |
|
|
nodiscard |
Get an index where there is no data in the array.
- Returns
- an index in the array which does not have data
- Exceptions
-
| AllocationException | when there are no free elements left |
◆ free()
| void Engine::Core::DescriptorIndexAllocator::free |
( |
uint32_t | index | ) |
|
Frees a cell in the array where the memory is not used anymore.
- Parameters
-
| index | the index in the array to release back into the pool of free memory |
◆ getCapacity()
| size_t Engine::Core::DescriptorIndexAllocator::getCapacity |
( |
| ) |
const |
◆ getUsedIndices()
| const std::vector< uint32_t > & Engine::Core::DescriptorIndexAllocator::getUsedIndices |
( |
| ) |
const |
|
nodiscard |
Gets the indices of all allocated fields in the array.
- Returns
- list of all indices of allocated cells in the array
◆ reset()
| void Engine::Core::DescriptorIndexAllocator::reset |
( |
int | newSize | ) |
|
Resets all values in the buffers and allocates with new size.
- Parameters
-
| newSize | Size of the new allocator |
◆ capacity
| uint32_t Engine::Core::DescriptorIndexAllocator::capacity |
|
private |
◆ freeIndices
| std::stack<uint32_t> Engine::Core::DescriptorIndexAllocator::freeIndices |
|
private |
◆ usedIndices
| std::vector<uint32_t> Engine::Core::DescriptorIndexAllocator::usedIndices |
|
private |
The documentation for this class was generated from the following file: