![]() |
NDEVR
API Documentation
|
Specific logic for reserving memory for a Buffer. More...
Public Types | |
| typedef ObjectAllocator< t_type, t_is_primitive, t_index_type > | allocator |
| The object allocator type for constructing and destructing elements. | |
| using | index_type = t_index_type |
| The index type used for element addressing. | |
Public Member Functions | |
| constexpr | BufferAllocator () noexcept |
| Default constructor. | |
| constexpr | BufferAllocator (BufferAllocator &&allocator) noexcept |
| Move constructor. | |
| ~BufferAllocator () noexcept | |
| Destructor. | |
| constexpr void | addIndex () noexcept |
| Appends one uninitialized element at the end of the buffer without managed growth. | |
| constexpr void | addIndex (t_index_type location) noexcept |
| Inserts one uninitialized element at the specified location, shifting subsequent elements. | |
| void | addLast () noexcept |
| Appends one uninitialized element to the end of the buffer without managed growth. | |
| template<bool t_auto_set_capacity> | |
| constexpr void | allocationSizeCheck (t_index_type new_size) noexcept |
| Checks if the buffer needs to grow and allocates accordingly. | |
| void | autoSetCapacity (t_index_type size) noexcept |
| Automatically sets the buffer capacity using the growth strategy defined by NextCapacityBytes. | |
| constexpr decltype(auto) | begin () const noexcept |
| Returns a const pointer to the beginning of the buffer. | |
| constexpr decltype(auto) | begin () noexcept |
| Returns a pointer to the beginning of the buffer. | |
| constexpr decltype(auto) | begin (t_index_type index) const noexcept |
| Returns a const pointer to the element at the given index. | |
| constexpr decltype(auto) | begin (t_index_type index) noexcept |
| Returns a pointer to the element at the given index. | |
| constexpr t_index_type | capacity () const noexcept |
| Returns the total allocated capacity of the buffer in elements. | |
| void | clear () noexcept |
| Clears the buffer by resetting the filled size to zero without freeing memory. | |
| sint04 | compare (const BufferAllocator &allocator) const noexcept |
| Performs a byte-level comparison of this buffer with another. | |
| sint04 | compare (const BufferAllocator &allocator, t_index_type start, t_index_type end) const noexcept |
| Performs a byte-level comparison of a sub-range of this buffer with another. | |
| template<class t_comparable_type> | |
| constexpr bool | contains (const t_comparable_type &value, t_index_type start, t_index_type size) const noexcept |
| Checks whether the buffer contains a given value within the specified range. | |
| constexpr t_index_type | count (const t_type &value) const noexcept |
| Counts the number of occurrences of a value in the buffer. | |
| template<bool t_managed> | |
| constexpr void | createSpace (t_index_type location, t_index_type size) noexcept |
| Creates additional space at a specific location, shifting existing elements forward. | |
| template<bool t_managed> | |
| constexpr void | createSpace (t_index_type size) noexcept |
| Creates additional space at the end of the buffer, optionally auto-managing capacity. | |
| template<bool t_is_null> | |
| decltype(auto) | emptyPtr () const noexcept |
| Returns a pointer to a static empty object for use when the buffer has no allocation. | |
| constexpr decltype(auto) | end () const noexcept |
| Returns a const pointer to one past the last filled element. | |
| constexpr decltype(auto) | end () noexcept |
| Returns a pointer to one past the last filled element. | |
| constexpr decltype(auto) | end (t_index_type index) noexcept |
| Returns a pointer to the element at the given offset from the end. | |
| constexpr t_index_type | filledSize () const noexcept |
| Returns the number of elements currently stored in the buffer. | |
| const t_type & | get (t_index_type index) const noexcept |
| Gets a const reference to the element at the given index. | |
| t_type & | get (t_index_type index) noexcept |
| Gets a mutable reference to the element at the given index. | |
| constexpr size_t | memSize () const noexcept |
| Returns the total memory size of the filled portion of the buffer in bytes. | |
| template<bool t_is_null> | |
| void | nullTerminatorCheck () noexcept |
| Writes a null terminator after the last filled element if null termination is enabled. | |
| BufferAllocator & | operator= (BufferAllocator &&value) noexcept |
| Move assignment operator. | |
| constexpr bool | ownsMemory () const |
| Checks whether this allocator owns its memory (i.e., has allocated capacity). | |
| constexpr decltype(auto) | ptr () const noexcept |
| Returns a const pointer to the underlying buffer, with optional alignment hint. | |
| constexpr decltype(auto) | ptr () noexcept |
| Returns a pointer to the underlying buffer, with optional alignment hint. | |
| constexpr void | reference (t_type *reference, t_index_type new_size) |
| Sets this allocator to reference external memory without owning it. | |
| void | removeAllIndex (t_index_type start, t_index_type end) noexcept |
| Removes a contiguous range of elements from the buffer. | |
| template<class t_range_buffer> | |
| void | removeAllIndices (const t_range_buffer &ranges) noexcept |
| Removes multiple contiguous ranges of elements from the buffer in a single pass. | |
| void | removeIndex (t_index_type location) noexcept |
| Removes an element at the specified location by shifting subsequent elements backward. | |
| void | removeLast () noexcept |
| Removes the last element from the buffer by decrementing the filled size. | |
| void | removeLast (t_index_type count) noexcept |
| Removes a specified number of elements from the end of the buffer. | |
| void | resizeSpace (t_index_type new_size) noexcept |
| Resizes the allocated memory to the specified number of elements. | |
| template<bool t_is_other_primitive, class t_other_index_type, bool t_other_null_term> | |
| void | setAll (const BufferAllocator< t_type, t_aligned_size, t_is_other_primitive, t_other_index_type, t_other_null_term > &allocator, t_index_type offset, t_index_type other_offset, t_index_type size) noexcept |
| Copies elements from another BufferAllocator into this buffer. | |
| void | setAll (const t_type &object, t_index_type offset, t_index_type size) noexcept |
| Fills a range of elements in the buffer with a single value. | |
| template<bool is_primitive> | |
| void | setAll (const t_type *src, t_index_type offset, t_index_type size) noexcept |
| Copies elements from a source array into this buffer. | |
| template<class t_other_allocator> | |
| void | setAllFromSource (const t_other_allocator &allocator, t_index_type offset, t_index_type other_offset, t_index_type size) noexcept |
| Copies elements from a generic source allocator into this buffer using element-wise assignment. | |
| void | setSize (t_index_type size) noexcept |
| Sets the filled size of the buffer, allocating more space if necessary. | |
| void | swap (t_index_type index_a, t_index_type index_b) noexcept |
| Swaps two elements in the buffer by index. | |
Static Public Member Functions | |
| static constexpr bool | IsNullTerm () noexcept |
| Checks whether this allocator uses null termination. | |
Specific logic for reserving memory for a Buffer.
When managed, and more memory is needed memory is reserved using the ([Current Capacity] * 3) / 2) + 1
Definition at line 527 of file MemoryManager.h.
|
inlineexplicitconstexprnoexcept |
Default constructor.
Initializes the allocator with an empty buffer and zero size.
Definition at line 542 of file MemoryManager.h.
References emptyPtr(), and m_buffer.
Referenced by BufferAllocator(), compare(), compare(), operator=(), and setAll().
|
inlineconstexprnoexcept |
Move constructor.
Takes ownership of the other allocator's memory via swap.
| [in] | allocator | The allocator to move from. |
Definition at line 551 of file MemoryManager.h.
References BufferAllocator(), emptyPtr(), and m_buffer.
|
inlinenoexcept |
Destructor.
Frees the allocated memory using the appropriate deallocation strategy.
Definition at line 563 of file MemoryManager.h.
References capacity(), and ptr().
|
inlineconstexprnoexcept |
Inserts one uninitialized element at the specified location, shifting subsequent elements.
| [in] | location | The index at which to insert the element. |
Definition at line 665 of file MemoryManager.h.
References createSpace(), m_filled_size, and ptr().
|
inlineconstexprnoexcept |
Checks if the buffer needs to grow and allocates accordingly.
When managed (t_auto_set_capacity), uses the growth strategy for gradual expansion. Otherwise, allocates exactly what is needed.
| [in] | new_size | The required buffer size in elements. |
Definition at line 1042 of file MemoryManager.h.
References autoSetCapacity(), m_allocated_size, and resizeSpace().
Referenced by createSpace(), and setSize().
|
inlinenoexcept |
Automatically sets the buffer capacity using the growth strategy defined by NextCapacityBytes.
| [in] | size | The minimum required capacity in elements. |
Definition at line 1016 of file MemoryManager.h.
References m_allocated_size, NextCapacityBytes(), and resizeSpace().
Referenced by allocationSizeCheck().
|
inlinenodiscardconstexprnoexcept |
Returns a const pointer to the beginning of the buffer.
Definition at line 787 of file MemoryManager.h.
References ptr().
|
inlinenodiscardconstexprnoexcept |
Returns a pointer to the beginning of the buffer.
Definition at line 778 of file MemoryManager.h.
References ptr().
Referenced by createSpace().
|
inlinenodiscardconstexprnoexcept |
Returns a const pointer to the element at the given index.
| [in] | index | The index of the element. |
Definition at line 797 of file MemoryManager.h.
References ptr().
|
inlinenodiscardconstexprnoexcept |
Returns a pointer to the element at the given index.
| [in] | index | The index of the element. |
Definition at line 806 of file MemoryManager.h.
References ptr().
|
inlinenodiscardconstexprnoexcept |
Returns the total allocated capacity of the buffer in elements.
Definition at line 840 of file MemoryManager.h.
References m_allocated_size.
Referenced by ~BufferAllocator(), nullTerminatorCheck(), and resizeSpace().
|
inlinenodiscardnoexcept |
Performs a byte-level comparison of this buffer with another.
| [in] | allocator | The other buffer allocator to compare against. |
Definition at line 689 of file MemoryManager.h.
References BufferAllocator(), cast(), getMin(), m_filled_size, and ptr().
|
inlinenodiscardnoexcept |
Performs a byte-level comparison of a sub-range of this buffer with another.
| [in] | allocator | The other buffer allocator to compare against. |
| [in] | start | The starting index for the comparison. |
| [in] | end | The ending index for the comparison. |
Definition at line 700 of file MemoryManager.h.
References BufferAllocator(), cast(), end(), getMin(), m_filled_size, and ptr().
|
inlinenodiscardconstexprnoexcept |
Checks whether the buffer contains a given value within the specified range.
| [in] | value | The value to search for. |
| [in] | start | The starting index of the search range. |
| [in] | size | The number of elements to search through. |
Definition at line 645 of file MemoryManager.h.
References ptr().
|
inlinenodiscardconstexprnoexcept |
Counts the number of occurrences of a value in the buffer.
| [in] | value | The value to search for. |
Definition at line 627 of file MemoryManager.h.
References count(), m_filled_size, and ptr().
Referenced by count(), and removeLast().
|
inlineconstexprnoexcept |
Creates additional space at a specific location, shifting existing elements forward.
| [in] | location | The index at which to insert the space. |
| [in] | size | The number of elements of space to create. |
Definition at line 593 of file MemoryManager.h.
References begin(), createSpace(), and m_filled_size.
|
inlineconstexprnoexcept |
Creates additional space at the end of the buffer, optionally auto-managing capacity.
| [in] | size | The number of elements of space to create. |
Definition at line 580 of file MemoryManager.h.
References allocationSizeCheck(), m_filled_size, and nullTerminatorCheck().
Referenced by addIndex(), addIndex(), addLast(), and createSpace().
|
inlinenodiscardnoexcept |
Returns a pointer to a static empty object for use when the buffer has no allocation.
Provides null termination without requiring a heap allocation.
Definition at line 1120 of file MemoryManager.h.
Referenced by BufferAllocator(), BufferAllocator(), and resizeSpace().
|
inlinenodiscardconstexprnoexcept |
Returns a const pointer to one past the last filled element.
Definition at line 823 of file MemoryManager.h.
References m_filled_size, and ptr().
|
inlinenodiscardconstexprnoexcept |
Returns a pointer to one past the last filled element.
Definition at line 815 of file MemoryManager.h.
References m_filled_size, and ptr().
Referenced by compare(), removeAllIndex(), and removeAllIndices().
|
inlinenodiscardconstexprnoexcept |
Returns a pointer to the element at the given offset from the end.
| [in] | index | The offset from the end of the buffer. |
Definition at line 832 of file MemoryManager.h.
References get(), and m_filled_size.
|
inlinenodiscardconstexprnoexcept |
Returns the number of elements currently stored in the buffer.
Definition at line 848 of file MemoryManager.h.
References m_filled_size.
|
inlinenodiscardnoexcept |
Gets a const reference to the element at the given index.
| [in] | index | The index of the element. |
Definition at line 745 of file MemoryManager.h.
References ptr().
|
inlinenodiscardnoexcept |
Gets a mutable reference to the element at the given index.
| [in] | index | The index of the element. |
Definition at line 736 of file MemoryManager.h.
References ptr().
Referenced by end().
|
inlinestaticnodiscardconstexprnoexcept |
Checks whether this allocator uses null termination.
Definition at line 537 of file MemoryManager.h.
|
inlinenodiscardconstexprnoexcept |
Returns the total memory size of the filled portion of the buffer in bytes.
Definition at line 864 of file MemoryManager.h.
References m_filled_size.
|
inlinenoexcept |
Move assignment operator.
Swaps internal state with the other allocator.
| [in] | value | The allocator to move-assign from. |
Definition at line 1148 of file MemoryManager.h.
References BufferAllocator(), m_allocated_size, m_buffer, and m_filled_size.
|
inlinenodiscardconstexpr |
Checks whether this allocator owns its memory (i.e., has allocated capacity).
Definition at line 856 of file MemoryManager.h.
References m_allocated_size.
|
inlinenodiscardconstexprnoexcept |
Returns a const pointer to the underlying buffer, with optional alignment hint.
Definition at line 766 of file MemoryManager.h.
References m_buffer.
|
inlinenodiscardconstexprnoexcept |
Returns a pointer to the underlying buffer, with optional alignment hint.
Definition at line 754 of file MemoryManager.h.
References m_buffer.
Referenced by ~BufferAllocator(), addIndex(), begin(), begin(), begin(), begin(), compare(), compare(), contains(), count(), end(), end(), get(), get(), nullTerminatorCheck(), removeAllIndex(), removeAllIndices(), removeIndex(), resizeSpace(), setAll(), setAll(), setAll(), setAllFromSource(), and swap().
|
inlineconstexpr |
Sets this allocator to reference external memory without owning it.
Any previously allocated memory is freed first.
| [in] | reference | Pointer to the external memory to reference. |
| [in] | new_size | The number of elements in the referenced memory. |
Definition at line 1029 of file MemoryManager.h.
References m_buffer, m_filled_size, reference(), and resizeSpace().
Referenced by reference().
|
inlinenoexcept |
Removes a contiguous range of elements from the buffer.
| [in] | start | The starting index of the range to remove (inclusive). |
| [in] | end | The ending index of the range to remove (exclusive). |
Definition at line 1068 of file MemoryManager.h.
References end(), m_filled_size, nullTerminatorCheck(), and ptr().
|
inlinenoexcept |
Removes multiple contiguous ranges of elements from the buffer in a single pass.
| [in] | ranges | A buffer of index pairs defining the ranges to remove. |
Definition at line 1087 of file MemoryManager.h.
References end(), m_filled_size, nullTerminatorCheck(), and ptr().
|
inlinenoexcept |
Removes an element at the specified location by shifting subsequent elements backward.
| [in] | location | The index of the element to remove. |
Definition at line 677 of file MemoryManager.h.
References m_filled_size, nullTerminatorCheck(), and ptr().
|
inlinenoexcept |
Removes a specified number of elements from the end of the buffer.
| [in] | count | The number of elements to remove. |
Definition at line 617 of file MemoryManager.h.
References count(), m_filled_size, and nullTerminatorCheck().
|
inlinenoexcept |
Resizes the allocated memory to the specified number of elements.
Handles allocation, reallocation, freeing, and reference-to-owned transitions.
| [in] | new_size | The new capacity in elements. If zero, the memory is freed. |
Definition at line 873 of file MemoryManager.h.
References capacity(), emptyPtr(), m_allocated_size, m_buffer, m_filled_size, ptr(), and setAll().
Referenced by allocationSizeCheck(), autoSetCapacity(), and reference().
|
inlinenoexcept |
Copies elements from another BufferAllocator into this buffer.
| [in] | allocator | The source buffer allocator to copy from. |
| [in] | offset | The destination offset in this buffer. |
| [in] | other_offset | The source offset in the other allocator. |
| [in] | size | The number of elements to copy. |
Definition at line 985 of file MemoryManager.h.
References BufferAllocator(), and ptr().
|
inlinenoexcept |
Fills a range of elements in the buffer with a single value.
| [in] | object | The value to assign to each element. |
| [in] | offset | The starting index for the fill operation. |
| [in] | size | The number of elements to fill. |
Definition at line 950 of file MemoryManager.h.
References ptr().
Referenced by resizeSpace().
|
inlinenoexcept |
Copies elements from a source array into this buffer.
Uses memmove for primitives and element-wise assignment for non-primitives.
| [in] | src | Pointer to the source data array. |
| [in] | offset | The destination offset in this buffer. |
| [in] | size | The number of elements to copy. |
Definition at line 963 of file MemoryManager.h.
References ptr().
|
inlinenoexcept |
Copies elements from a generic source allocator into this buffer using element-wise assignment.
| [in] | allocator | The source allocator to copy from. |
| [in] | offset | The destination offset in this buffer. |
| [in] | other_offset | The source offset in the other allocator. |
| [in] | size | The number of elements to copy. |
Definition at line 1005 of file MemoryManager.h.
References ptr().
|
inlinenoexcept |
Sets the filled size of the buffer, allocating more space if necessary.
| [in] | size | The new filled size. |
Definition at line 725 of file MemoryManager.h.
References allocationSizeCheck(), m_filled_size, and nullTerminatorCheck().
|
inlinenoexcept |
Swaps two elements in the buffer by index.
| [in] | index_a | The index of the first element. |
| [in] | index_b | The index of the second element. |
Definition at line 709 of file MemoryManager.h.
References ptr().