A class that manages a pool of objects that are stored at persistent locations in memory.
More...
|
| ObjectPool () |
| Create a new empty object pool without any memory allocated. More...
|
|
| ObjectPool (const ObjectPool &other) |
| Create a new empty object pool that copies the state of another pool. More...
|
|
| ~ObjectPool () |
| Destroy an object pool, releasing any allocated memory and destructing all objects. More...
|
|
ObjectPool & | operator= (const ObjectPool &other) |
| Assign the state of another ObjectPool to this one, copying its elements. More...
|
|
SizeType | getSize () const |
| Return the current number of valid objects there are in the pool. More...
|
|
SizeType | getCapacity () const |
| Return the current number of objects that the pool can store without allocating more memory. More...
|
|
T & | operator[] (SizeType objectIndex) |
| Return a reference to the array element at the specified index. More...
|
|
const T & | operator[] (SizeType objectIndex) const |
| Return a const reference to the array element at the specified index. More...
|
|
Bool | isUsed (SizeType objectIndex) const |
| Return whether or not the object with the given index is currently constructed. More...
|
|
Bool | isUnused (SizeType objectIndex) const |
| Return whether or not the object with the given index is currently not constructed. More...
|
|
SizeType | add (const T &prototype) |
| Copy an object and add the copy to the object pool, returning the object's index in the pool. More...
|
|
SizeType | addNew () |
| Construct an object in-place using the given parameters, returning the object's index in the pool. More...
|
|
template<typename P1 > |
SizeType | addNew (const P1 &p1) |
| Construct an object in-place using the given parameters, returning the object's index in the pool. More...
|
|
template<typename P1 , typename P2 > |
SizeType | addNew (const P1 &p1, const P2 &p2) |
| Construct an object in-place using the given parameters, returning the object's index in the pool. More...
|
|
template<typename P1 , typename P2 , typename P3 > |
SizeType | addNew (const P1 &p1, const P2 &p2, const P3 &p3) |
| Construct an object in-place using the given parameters, returning the object's index in the pool. More...
|
|
template<typename P1 , typename P2 , typename P3 , typename P4 > |
SizeType | addNew (const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) |
| Construct an object in-place using the given parameters, returning the object's index in the pool. More...
|
|
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 > |
SizeType | addNew (const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) |
| Construct an object in-place using the given parameters, returning the object's index in the pool. More...
|
|
void | remove (SizeType objectIndex) |
| Remove and destroy the object with the specified index in this pool. More...
|
|
void | clear () |
| Remove all objects from the pool. More...
|
|
Iterator | getIterator () |
| Return an object that iterates over the valid objects in this object pool. More...
|
|
template<typename T, Size blockSizeLog2 = Size(3), typename SizeType = Size, typename AllocatorType = Allocator>
class om::util::ObjectPool< T, blockSizeLog2, SizeType, AllocatorType >
A class that manages a pool of objects that are stored at persistent locations in memory.
The object pool allocates blocks of objects of a fixed power-of-two size contiguously in memory for better cache performance than if each object were allocated separately. A single contiguous array of objects cannot be used because it would cause objects to be reallocated if the array grows in size.
template<typename T, Size blockSizeLog2 = Size(3), typename SizeType = Size, typename AllocatorType = Allocator>
template<typename P1 , typename P2 >
SizeType om::util::ObjectPool< T, blockSizeLog2, SizeType, AllocatorType >::addNew |
( |
const P1 & |
p1, |
|
|
const P2 & |
p2 |
|
) |
| |
|
inline |
Construct an object in-place using the given parameters, returning the object's index in the pool.
template<typename T, Size blockSizeLog2 = Size(3), typename SizeType = Size, typename AllocatorType = Allocator>
template<typename P1 , typename P2 , typename P3 >
SizeType om::util::ObjectPool< T, blockSizeLog2, SizeType, AllocatorType >::addNew |
( |
const P1 & |
p1, |
|
|
const P2 & |
p2, |
|
|
const P3 & |
p3 |
|
) |
| |
|
inline |
Construct an object in-place using the given parameters, returning the object's index in the pool.
template<typename T, Size blockSizeLog2 = Size(3), typename SizeType = Size, typename AllocatorType = Allocator>
template<typename P1 , typename P2 , typename P3 , typename P4 >
SizeType om::util::ObjectPool< T, blockSizeLog2, SizeType, AllocatorType >::addNew |
( |
const P1 & |
p1, |
|
|
const P2 & |
p2, |
|
|
const P3 & |
p3, |
|
|
const P4 & |
p4 |
|
) |
| |
|
inline |
Construct an object in-place using the given parameters, returning the object's index in the pool.
template<typename T, Size blockSizeLog2 = Size(3), typename SizeType = Size, typename AllocatorType = Allocator>
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
SizeType om::util::ObjectPool< T, blockSizeLog2, SizeType, AllocatorType >::addNew |
( |
const P1 & |
p1, |
|
|
const P2 & |
p2, |
|
|
const P3 & |
p3, |
|
|
const P4 & |
p4, |
|
|
const P5 & |
p5 |
|
) |
| |
|
inline |
Construct an object in-place using the given parameters, returning the object's index in the pool.