|
Foundation
|
Unbounded object pool with O(1) value mapping. More...
#include <Pool.hpp>
Public Member Functions | |
| Pool (Allocator *alloc) | |
| bool | Contains (K key) const |
| Checks if the specified key exists and has a value. | |
| V * | At (K key) const |
| Retrieves a reference to the value associated with the given key. NOTE: Calling this function with a key that's not retrieved from pop() is undefined behavior. | |
| template<typename... Args> | |
| K | Pop (Args &&... args) |
| Allocates a new key in the pool and constructs the object in-place. | |
| template<typename Derived , typename... Args> | |
| K | PopBase (Args &&... args) |
| Allocates a new key in the pool and constructs a derived object in-place. | |
| void | Free (K key) |
| Frees the value associated with the specified key. | |
Private Member Functions | |
| void | Push (K key) |
| Adds a key to the internal key container and resizes the value container if necessary. | |
| void | CheckContains (K key) const |
| K | PopKey () |
Private Attributes | |
| Allocator * | mAlloc |
| Vector< K > | mKeys |
| Vector< UniquePtr< V > > | mValues |
| std::mutex | mMutex |
| K | mTop {} |
Unbounded object pool with O(1) value mapping.
| K | Key type. Should be an integral type. |
| V | Value type. |
Retrieves a reference to the value associated with the given key. NOTE: Calling this function with a key that's not retrieved from pop() is undefined behavior.
|
inlineprivate |
|
inline |
Checks if the specified key exists and has a value.
Frees the value associated with the specified key.
|
inline |
Allocates a new key in the pool and constructs the object in-place.
|
inline |
Allocates a new key in the pool and constructs a derived object in-place.
| Derived | The derived type to construct, based on the base type V. |
Adds a key to the internal key container and resizes the value container if necessary.