Template for creating arrays of intrinsic objects. More...
Public Types | |
typedef T * | iterator |
STL compatible iterator. | |
typedef const T * | const_iterator |
STL compatible iterator. | |
typedef T | value_type |
STL compatible type declaration. | |
Public Member Functions | |
SimpleArray () noexcept | |
Default constructor. | |
SimpleArray (uintptr_t uDefault) noexcept | |
Default constructor with a starting array. | |
T * | GetPtr (void) noexcept |
Obtain a pointer to the array. | |
const T * | GetPtr (void) const noexcept |
Obtain a constant pointer to the array. | |
T * | data (void) noexcept |
Obtain a pointer to the array. | |
const T * | data (void) const noexcept |
Obtain a constant pointer to the array. | |
T & | operator[] (uintptr_t uIndex) noexcept |
Obtain a reference to an item in the array. | |
const T & | operator[] (uintptr_t uIndex) const noexcept |
Obtain a constant reference to an item in the array. | |
T & | GetIndexedItem (uintptr_t uIndex) |
Obtain a reference to an item in the array. | |
const T & | GetIndexedItem (uintptr_t uIndex) const noexcept |
Obtain a constant reference to an item in the array. | |
uintptr_t | capacity (void) const noexcept |
Return the number of objects the current buffer could hold. | |
uintptr_t | size (void) const noexcept |
Return the valid number of objects in the array. | |
uint_t | empty (void) const noexcept |
Return TRUE if the array is empty. | |
T & | front (void) noexcept |
Obtain a reference to first item in the array. | |
const T & | front (void) const noexcept |
Obtain a constant reference to first item in the array. | |
T & | back (void) noexcept |
Obtain a reference to last item in the array. | |
const T & | back (void) const noexcept |
Obtain a constant reference to last item in the array. | |
eError | push_back (T rData) noexcept |
Append an object to the end of the array. | |
eError | pop_back (void) noexcept |
Remove an object from the end of the array. | |
SimpleArray< T > & | operator= (const SimpleArray< T > &rData) noexcept |
Copy an array into this one. | |
eError | insert_at (uintptr_t uIndex, T rData=T()) noexcept |
Insert an object into the array. | |
uint_t | remove (T rData) noexcept |
Find an item and remove it from the array. | |
uint_t | contains (T rData) const noexcept |
Find an item in the array. | |
eError | append (const T *pSourceData, uintptr_t uCount) noexcept |
Append an array of object to this array. | |
eError | append (const SimpleArray< T > &rData) noexcept |
Append an array to this array. | |
iterator | begin (void) noexcept |
Iterator for the start of the array. | |
iterator | end (void) noexcept |
Iterator for the end of the array. | |
const_iterator | begin (void) const noexcept |
Constant iterator for the start of the array. | |
const_iterator | end (void) const noexcept |
Constant iterator for the end of the array. | |
const_iterator | cbegin (void) const noexcept |
Constant iterator for the start of the array. | |
const_iterator | cend (void) const noexcept |
Constant iterator for the end of the array. | |
eError | erase (const_iterator it) noexcept |
Remove an entry from the array using an iterator as the index. | |
Public Member Functions inherited from Burger::SimpleArrayBase | |
SimpleArrayBase (uintptr_t uChunkSize) noexcept | |
Default constructor. | |
SimpleArrayBase (uintptr_t uChunkSize, uintptr_t uDefault) noexcept | |
Default constructor with a starting array and chunk size. | |
SimpleArrayBase (const SimpleArrayBase &rData) noexcept | |
Default constructor for making a copy of another SimpleArrayBase. | |
~SimpleArrayBase () | |
Standard destructor. | |
SimpleArrayBase & | operator= (const SimpleArrayBase &rData) noexcept |
Copy an array into this one. | |
void | clear (void) noexcept |
Remove all objects from the array. | |
eError | remove_at (uintptr_t uIndex) noexcept |
Remove an object from the array. | |
eError | resize (uintptr_t uNewSize) noexcept |
Resize the valid entry count of the array. | |
eError | reserve (uintptr_t uNewBufferSize) noexcept |
Resize the memory used by the array. | |
Static Public Member Functions | |
static uintptr_t | max_size (void) noexcept |
Return the maximum number of objects the buffer could ever hold. | |
Additional Inherited Members | |
Protected Member Functions inherited from Burger::SimpleArrayBase | |
eError | append (const void *pData, uintptr_t uCount) noexcept |
Append an array of object to this array. | |
Protected Attributes inherited from Burger::SimpleArrayBase | |
void * | m_pData |
Pointer to the array of class instances. | |
uintptr_t | m_uSize |
Number of active elements in the array. | |
uintptr_t | m_uBufferSize |
Maximum number of elements in the array. | |
uintptr_t | m_uChunkSize |
Size in bytes for each individual element in the array. | |
Template for creating arrays of intrinsic objects.
This template class will dynamically allocate memory as needed. Since it's assuming the data is of intrinsic values, no initialization or shutdown is performed on the elements. If this behavior is desired, use the ClassArray template instead.
While it uses function names that match the class vector<T>, this is a lightweight version which doesn't match 100% due to implementation for performance.
const T* Burger::SimpleArray< T >::const_iterator |
STL compatible iterator.
Constant iterator object for using functions in <algorithm>
T* Burger::SimpleArray< T >::iterator |
STL compatible iterator.
Iterator object for using functions in <algorithm>
T Burger::SimpleArray< T >::value_type |
STL compatible type declaration.
Type declarator to use in functions in <algorithm>. It's used to create variables of T by using this typedef in the class.
|
inlinenoexcept |
Default constructor.
Initializes the array to contain no data and have no members.
Initializes the array to contain no data and have no members.
|
inlinenoexcept |
Default constructor with a starting array.
Initializes the array to contain uDefault number of uninitialized members.
uDefault | Number of members to create the array with. Zero will generate an empty array. |
|
inlinenoexcept |
Append an array to this array.
Given another array, iterate over the objects contained within and copy them to the end of this array. This function will increase the size of the buffer if needed.
rData | Reference to a like typed SimpleArray to copy from. |
|
inlinenoexcept |
Append an array of object to this array.
Given a base pointer and an object count, iterate over the objects and copy them to the end of this array. This function will increase the size of the buffer if needed.
pSourceData | Pointer to the first element in an array of objects |
uCount | Number of elements in the array |
|
inlinenoexcept |
Obtain a constant reference to last item in the array.
Return a constant reference to the last object.
|
inlinenoexcept |
Obtain a reference to last item in the array.
Return a reference to the last object.
|
inlinenoexcept |
Constant iterator for the start of the array.
STL compatible constant iterator for the start of the array.
|
inlinenoexcept |
Iterator for the start of the array.
STL compatible iterator for the start of the array.
|
inlinenoexcept |
Return the number of objects the current buffer could hold.
The buffer size may exceed the number of valid objects, so that if the array grew, memory allocations won't be needed. This function will return the size of the true buffer.
|
inlinenoexcept |
Constant iterator for the start of the array.
STL compatible constant iterator for the start of the array.
|
inlinenoexcept |
Constant iterator for the end of the array.
STL compatible constant iterator for the end of the array.
|
inlinenoexcept |
Find an item in the array.
Given an item, scan the array for an element that matches the value.
rData | Copy of the item to search for |
|
inlinenoexcept |
Obtain a constant pointer to the array.
Allow direct access to the base pointer to the array. This can be nullptr if the array is empty.
|
inlinenoexcept |
Obtain a pointer to the array.
Allow direct access to the base pointer to the array. This can be nullptr if the array is empty.
|
inlinenoexcept |
Return TRUE if the array is empty.
If there is no valid data in the array, return TRUE.
|
inlinenoexcept |
Constant iterator for the end of the array.
STL compatible constant iterator for the end of the array.
|
inlinenoexcept |
Iterator for the end of the array.
STL compatible iterator for the end of the array.
|
inlinenoexcept |
Remove an entry from the array using an iterator as the index.
Using an iterator index, delete an entry in the array. Note, this will change the end() value in an index
it | Iterator index into an array |
|
inlinenoexcept |
Obtain a constant reference to first item in the array.
Return a constant reference to the first object.
|
inlinenoexcept |
Obtain a reference to first item in the array.
Return a reference to the first object.
|
inline |
Obtain a reference to an item in the array.
Index into the array and return a reference to the object.
uIndex | Object number in the array to retrieve a reference to. |
|
inlinenoexcept |
Obtain a constant reference to an item in the array.
Index into the array and return a constant reference to the object.
uIndex | Object number in the array to retrieve a constant reference to. |
|
inlinenoexcept |
Obtain a constant pointer to the array.
Allow direct access to the base pointer to the array. This can be nullptr if the array is empty.
|
inlinenoexcept |
Obtain a pointer to the array.
Allow direct access to the base pointer to the array. This can be nullptr if the array is empty.
|
inlinenoexcept |
Insert an object into the array.
Expand the buffer if needed and make a copy of the rData object into the array at the index uIndex.
uIndex | Index into the array for the location of the object to insert. |
rData | Reference to the object to copy into the array |
|
inlinestaticnoexcept |
Return the maximum number of objects the buffer could ever hold.
Given the maximum possible size of memory in the machine, return the theoretical maximum number of objects the buffer could hold.
|
inlinenoexcept |
Copy an array into this one.
If the copy is not itself, call clear() to erase the contents of this class and make a duplicate of every entry in the rData class into this one.
rData | Reference to a matching SimpleArray type |
|
inlinenoexcept |
Obtain a constant reference to an item in the array.
Index into the array and return a constant reference to the object.
uIndex | Object number in the array to retrieve a constant reference to. |
|
inlinenoexcept |
Obtain a reference to an item in the array.
Index into the array and return a reference to the object.
uIndex | Object number in the array to retrieve a reference to. |
|
inlinenoexcept |
Remove an object from the end of the array.
Call the destructor on the last object in the array and reduce the array size by one.
|
inlinenoexcept |
Append an object to the end of the array.
Make a copy of the object at the end of the array. If there is no room for the new object, increase the size of the buffer to make room. Buffer size increases are made in groups to reduce memory allocation calls to improve performance.
rData | An instance of the object to copy at the end of the array |
|
inlinenoexcept |
Find an item and remove it from the array.
Given an item, scan the array for the first element found and then remove the item.
rData | Copy of the item to remove |
|
inlinenoexcept |
Return the valid number of objects in the array.
This value is less than or equal to the buffer size.