Basically a bad std::vector without exceptions which can also work with foreign memory.
More...
|
| | HeapBuffer ()=default |
| |
| | HeapBuffer (const Size size) |
| | Setup the buffer with a size. More...
|
| |
| template<int Alignment2, class Allocator2 , typename Size2 > |
| | HeapBuffer (const HeapBuffer< T, Alignment2, Allocator2, Size2 > &source) |
| | Copy Constructor, calls set() Failed allocations have to be checked. More...
|
| |
| | HeapBuffer (const T *data, Size size) |
| |
| | HeapBuffer (HeapBuffer &&source) |
| | Move contructor, will mark the original buffer as injected. More...
|
| |
| HeapBuffer & | operator= (HeapBuffer &&source) |
| |
| HeapBuffer & | operator= (const HeapBuffer &)=delete |
| |
| | HeapBuffer (const HeapBuffer *)=delete |
| |
| | ~HeapBuffer () |
| |
| template<int Alignment2, class Allocator2 , typename Size2 > |
| bool | set (const HeapBuffer< T, Alignment2, Allocator2, Size2 > &source) |
| | Resizes and copies the contents of the source Buffer This will do a memory::copy,so none of the object contructors will called. More...
|
| |
| bool | set (const T *data, Size size) |
| | Set data from array. More...
|
| |
| void | inject (T *mem, const Size size, const Size realSize=0) |
| | Provide foreign memory to borrow. More...
|
| |
| void | inject (const T *mem, const Size size, const Size realSize=0) |
| | Provide const foreign memory to use Using non const accessors will cause assertions in debug mode. More...
|
| |
| void | disown () |
| | The memory is no longer manager by this instance. More...
|
| |
| bool | empty () const |
| |
| T * | data () |
| |
| const T * | data () const |
| |
| const T & | operator[] (const Size index) const |
| |
| T & | operator[] (const Size index) |
| |
| const T * | begin () const |
| |
| const T * | end () const |
| |
| T * | begin () |
| |
| T * | end () |
| |
| T & | last () |
| |
| T & | first () |
| |
| bool | reserve (const Size size) |
| | Will make sure the desired space is allocated. More...
|
| |
| bool | resize (const Size size, const bool downsize=true) |
| | Resize the buffer If the memory is borrowed it will become unique and owned by this instance as soon as an allocation happens. More...
|
| |
| bool | push (const T &object) |
| | Push the object to the back of the buffer TODO tklb move version. More...
|
| |
| bool | pop (T *object) |
| | Get the last element in the buffer. More...
|
| |
| bool | remove (const Size index) |
| | Removes the object at a given index and fills the gap with another Will never shrink the buffer/allocate. More...
|
| |
| bool | remove (const T &object) |
| | If a == comparisin is possible the object itself can be used. More...
|
| |
| bool | remove (const T *object) |
| | Otherwise use memory location. More...
|
| |
| bool | destroyPointers () |
| | If T is a pointer type, delete will be called for all pointers in buffer and resize(0) is called. More...
|
| |
| void | clear () |
| | Clears the buffer but doesn't free the memory. More...
|
| |
| bool | injected () const |
| | Whether the memory is managed by the instance or is borrowed. More...
|
| |
| Size | size () const |
| | Returns the amount of elements in the container. More...
|
| |
| Size | reserved () const |
| | Returns the real allocated size in elements. More...
|
| |
| Size | allocated () const |
| | Returns the size of the allocated space. More...
|
| |
template<typename T, size_t ALIGNMENT = 0, class ALLOCATOR = StdAllocator <unsigned char>, typename SIZE = unsigned int>
class tklb::HeapBuffer< T, ALIGNMENT, ALLOCATOR, SIZE >
Basically a bad std::vector without exceptions which can also work with foreign memory.
- Template Parameters
-
| T | Element type need to have a default contructor |
| ALIGNMENT | Memory alignment in bytes needs to be a power of 2. Defaults to 0 |
| ALLOCATOR | Normal allocator class defaults to non basic malloc/free wrapper |
| SIZE | Size type used for index, defaults to unsigned int to save some space |
Definition at line 49 of file THeapBuffer.hpp.
template<typename T , size_t ALIGNMENT = 0, class ALLOCATOR = StdAllocator <unsigned char>, typename SIZE = unsigned int>
template<int Alignment2, class Allocator2 , typename Size2 >
Copy Constructor, calls set() Failed allocations have to be checked.
Definition at line 92 of file THeapBuffer.hpp.
bool set(const HeapBuffer< T, Alignment2, Allocator2, Size2 > &source)
Resizes and copies the contents of the source Buffer This will do a memory::copy,so none of the objec...
template<typename T , size_t ALIGNMENT = 0, class ALLOCATOR = StdAllocator <unsigned char>, typename SIZE = unsigned int>
If T is a pointer type, delete will be called for all pointers in buffer and resize(0) is called.
Definition at line 349 of file THeapBuffer.hpp.
350 if (!std::is_pointer<T>::value) {
template<typename T , size_t ALIGNMENT = 0, class ALLOCATOR = StdAllocator <unsigned char>, typename SIZE = unsigned int>
Get the last element in the buffer.
Will never shrink the buffer/allocate
Definition at line 300 of file THeapBuffer.hpp.
301 if (0 ==
mSize) {
return false; }
template<typename T , size_t ALIGNMENT = 0, class ALLOCATOR = StdAllocator <unsigned char>, typename SIZE = unsigned int>
template<int Alignment2, class Allocator2 , typename Size2 >
Resizes and copies the contents of the source Buffer This will do a memory::copy,so none of the object contructors will called.
- Returns
- True on success
Definition at line 132 of file THeapBuffer.hpp.
133 return set(source.data(), source.size());
template<typename T , size_t ALIGNMENT = 0, class ALLOCATOR = StdAllocator <unsigned char>, typename SIZE = unsigned int>
the actually allocated size if it's 0 the memory is not actually owned by the buffer and won't be delete with the object.
No safety mechanism if memory becomes invalid
Definition at line 72 of file THeapBuffer.hpp.