Array allocator. More...
#include <ArrayAllocator.hpp>
Public Types | |
| using | value_type = T |
| Element type. | |
| using | size_type = typename std::vector< value_type >::size_type |
| Size type. | |
| using | reference = typename std::vector< value_type >::reference |
| Reference type alias. | |
| using | const_reference = typename std::vector< value_type >::const_reference |
| Constant reference type alias. | |
Public Member Functions | |
| size_type | GetIndex (value_type *ptr) const |
| Gets the index of the given pointer. More... | |
| template<class... Args> | |
| size_type | Allocate (Args &&... args) |
| Allocates an entry in the array with the given constructor parameters. More... | |
| size_type | Allocate (const value_type ©) |
| Allocates an entry in the array with the given instance. More... | |
| void | Free (size_type index) |
| Frees the previously-allocated index entry. More... | |
| bool | FindFree (size_type index) const noexcept |
| Finds whether the given index is in the free list. More... | |
| reference | operator[] (size_type pos) |
| Array index operator. More... | |
| const_reference | operator[] (size_type pos) const |
| Constant array index operator. More... | |
| reference | at (size_type pos) |
| Bounds checking indexed array accessor. | |
| const_reference | at (size_type pos) const |
| Bounds checking indexed array accessor. | |
| size_type | size () const noexcept |
| Gets the size of this instance in number of elements. More... | |
| size_type | max_size () const noexcept |
| Gets the maximum theoretical size this instance can have in number of elements. | |
| size_type | free_size () const noexcept |
| Gets the number of elements currently free. More... | |
| void | reserve (size_type value) |
| Reserves the given number of elements from dynamic memory. More... | |
| void | clear () noexcept |
| Clears this instance's free pool and allocated pool. | |
Private Attributes | |
| std::vector< value_type > | m_data |
| Array data (both used & free). | |
| std::vector< size_type > | m_free |
| Indices of free elements. | |
Array allocator.
|
inline |
Allocates an entry in the array with the given constructor parameters.
Free(size_type) if the allocated entry needs to be freed. size() - free_size() will return a value one less than before. Referenced by playrho::d2::WorldImpl::CreateBody(), and playrho::d2::WorldImpl::CreateFixture().
|
inline |
Allocates an entry in the array with the given instance.
Free(size_type) if the allocated entry needs to be freed. size() - free_size() will return a value one less than before.
|
inlinenoexcept |
Finds whether the given index is in the free list.
|
inline |
Frees the previously-allocated index entry.
FindFree(size_type) returns true for the freed index. free_size() returns a value one greater than before. | std::out_of_range | if given an index that's greater than or equal to the size of this instance as returned by size(). |
Referenced by playrho::d2::WorldImpl::Destroy().
|
inlinenoexcept |
Gets the number of elements currently free.
|
inline |
Gets the index of the given pointer.
|
inline |
|
inline |
|
inline |
Reserves the given number of elements from dynamic memory.
|
inlinenoexcept |