|
| LinearPool () |
| Creates a new empty linear pool.
|
|
| ~LinearPool () |
| Destroys linear pool.
|
|
template<typename... Args> |
ID< T > | create (Args &&... args) |
| Creates a new item in the pool.
|
|
void | destroy (ID< T > instance) |
| Destroys linear pool item.
|
|
View< T > | get (ID< T > instance) const noexcept |
| Returns View of the item in the linear pool.
|
|
View< T > | get (const Ref< T > &instance) const noexcept |
| Returns View of the item in the linear pool.
|
|
ID< T > | getID (const T *instance) const noexcept |
| Returns ID of the item pointer.
|
|
T * | getData () noexcept |
| Returns linear pool item memory block.
|
|
const T * | getData () const noexcept |
| Returns linear pool constant item memory block.
|
|
uint32_t | getCount () const noexcept |
| Returns current created item count.
|
|
uint32_t | getOccupancy () const noexcept |
| Returns linear memory used item slots count.
|
|
void | clear (bool destroyItems=DestroyItems) |
| Destroys all items in the linear pool.
|
|
void | dispose () |
| Actually destroys items.
|
|
Iterator | begin () noexcept |
| Returns an iterator pointing to the first element in the items array.
|
|
Iterator | end () noexcept |
| Returns an iterator pointing to the past-the-end element in the items array.
|
|
ConstantIterator | begin () const noexcept |
| Returns a constant iterator pointing to the first element in the items array.
|
|
ConstantIterator | end () const noexcept |
| Returns a constant iterator pointing to the past-the-end element in the items array.
|
|
template<class T, bool DestroyItems>
class ecsm::LinearPool< T, DestroyItems >
Item array with linear memory block.
In a linear pool, a fixed-size block of memory is pre-allocated, and individual items or objects are then allocated from this pool. The linear allocation strategy means that these items are placed sequentially in memory, which can improve cache locality. Cache locality refers to the tendency of accessing nearby memory locations at the same time, which can result in better performance due to the way modern computer architectures use caches.
- Template Parameters
-
T | type of the item in the linear pool |
DestroyItems | linear pool should call destroy() function of the items |
template<class T , bool DestroyItems>
template<typename... Args>
ID< T > create |
( |
Args &&... | args | ) |
|
|
inline |
Creates a new item in the pool.
Reallocates linear memory block or reuses free item slots.
- Warning
- This function can reallocate items memory and invalidate all previous View.
- Parameters
-
args | additional item arguments or empty |
- Returns
- A new item identifier in the linear pool.