Self reallocating template array (like stl vector) with additional features. More...
#include <irrArray.h>
Self reallocating template array (like stl vector) with additional features.
Some features are: Heap sorting, binary search methods, easier debugging.
Definition at line 22 of file irrArray.h.
irr::core::array< T, TAlloc >::array | ( | ) | [inline] |
Default constructor for empty array.
Definition at line 28 of file irrArray.h.
Referenced by irr::core::string< fschar_t >::operator<().
irr::core::array< T, TAlloc >::array | ( | u32 | start_count | ) | [inline] |
Constructs an array and allocates an initial chunk of memory.
start_count | Amount of elements to pre-allocate. |
Definition at line 37 of file irrArray.h.
irr::core::array< T, TAlloc >::array | ( | const array< T, TAlloc > & | other | ) | [inline] |
Copy constructor.
Definition at line 46 of file irrArray.h.
irr::core::array< T, TAlloc >::~array | ( | ) | [inline] |
Destructor.
Frees allocated memory, if set_free_when_destroyed was not set to false by the user before.
Definition at line 55 of file irrArray.h.
u32 irr::core::array< T, TAlloc >::allocated_size | ( | ) | const [inline] |
Get amount of memory allocated.
Definition at line 377 of file irrArray.h.
Referenced by irr::scene::SMD3QuaternionTagList::set_used().
s32 irr::core::array< T, TAlloc >::binary_search | ( | const T & | element | ) | [inline] |
Performs a binary search for an element, returns -1 if not found.
The array will be sorted before the binary search if it is not already sorted. Caution is advised! Be careful not to call this on unsorted const arrays, or the slower method will be used.
element | Element to search for. |
Definition at line 409 of file irrArray.h.
Referenced by irr::core::array< IMesh * >::binary_search(), and irr::core::array< IMesh * >::binary_search_multi().
s32 irr::core::array< T, TAlloc >::binary_search | ( | const T & | element | ) | const [inline] |
Performs a binary search for an element if possible, returns -1 if not found.
This method is for const arrays and so cannot call sort(), if the array is not sorted then linear_search will be used instead. Potentially very slow!
element | Element to search for. |
Definition at line 422 of file irrArray.h.
s32 irr::core::array< T, TAlloc >::binary_search | ( | const T & | element, |
s32 | left, | ||
s32 | right | ||
) | const [inline] |
Performs a binary search for an element, returns -1 if not found.
element,: | Element to search for. |
left | First left index |
right | Last right index. |
Definition at line 437 of file irrArray.h.
s32 irr::core::array< T, TAlloc >::binary_search_multi | ( | const T & | element, |
s32 & | last | ||
) | [inline] |
Performs a binary search for an element, returns -1 if not found. it is used for searching a multiset The array will be sorted before the binary search if it is not already sorted.
element | Element to search for. |
&last | return lastIndex of equal elements |
Definition at line 475 of file irrArray.h.
void irr::core::array< T, TAlloc >::clear | ( | ) | [inline] |
Clears the array and deletes all allocated memory.
Definition at line 203 of file irrArray.h.
Referenced by irr::scene::SMesh::clear(), irr::scene::SSkinMeshBuffer::convertTo2TCoords(), irr::scene::SSkinMeshBuffer::convertToTangents(), irr::scene::quake3::getAsStringList(), irr::scene::quake3::getTextures(), irr::core::array< IMesh * >::operator=(), irr::core::array< IMesh * >::set_pointer(), and irr::core::array< IMesh * >::~array().
const T* irr::core::array< T, TAlloc >::const_pointer | ( | ) | const [inline] |
Gets a const pointer to the array.
Definition at line 360 of file irrArray.h.
Referenced by irr::scene::SSharedMeshBuffer::getIndices(), irr::scene::CMeshBuffer< T >::getIndices(), irr::scene::SSkinMeshBuffer::getIndices(), irr::scene::CMeshBuffer< T >::getVertices(), irr::scene::SSharedMeshBuffer::getVertices(), and irr::scene::SSkinMeshBuffer::getVertices().
bool irr::core::array< T, TAlloc >::empty | ( | ) | const [inline] |
Check if array is empty.
Definition at line 385 of file irrArray.h.
Referenced by irr::scene::SAnimatedMesh::getMesh(), irr::scene::SAnimatedMesh::getMeshBuffer(), irr::scene::SAnimatedMesh::getMeshBufferCount(), irr::scene::SAnimatedMesh::recalculateBoundingBox(), irr::scene::SSharedMeshBuffer::recalculateBoundingBox(), irr::scene::CMeshBuffer< T >::recalculateBoundingBox(), and irr::scene::SSkinMeshBuffer::recalculateBoundingBox().
void irr::core::array< T, TAlloc >::erase | ( | u32 | index | ) | [inline] |
Erases an element from the array.
May be slow, because all elements following after the erased element have to be copied.
index,: | Index of element to be erased. |
Definition at line 536 of file irrArray.h.
void irr::core::array< T, TAlloc >::erase | ( | u32 | index, |
s32 | count | ||
) | [inline] |
Erases some elements from the array.
May be slow, because all elements following after the erased element have to be copied.
index,: | Index of the first element to be erased. |
count,: | Amount of elements to be erased. |
Definition at line 557 of file irrArray.h.
T& irr::core::array< T, TAlloc >::getLast | ( | ) | [inline] |
Gets last element.
Definition at line 333 of file irrArray.h.
const T& irr::core::array< T, TAlloc >::getLast | ( | ) | const [inline] |
Gets last element.
Definition at line 342 of file irrArray.h.
void irr::core::array< T, TAlloc >::insert | ( | const T & | element, |
u32 | index = 0 |
||
) | [inline] |
Insert item into array at specified position.
Please use this only if you know what you are doing (possible performance loss). The preferred method of adding elements should be push_back().
element,: | Element to be inserted |
index,: | Where position to insert the new element. |
Definition at line 135 of file irrArray.h.
Referenced by irr::core::array< IMesh * >::push_back(), and irr::core::array< IMesh * >::push_front().
s32 irr::core::array< T, TAlloc >::linear_reverse_search | ( | const T & | element | ) | const [inline] |
Finds an element in linear time, which is very slow.
Use binary_search for faster finding. Only works if ==operator is implemented.
element,: | Element to search for. |
Definition at line 522 of file irrArray.h.
s32 irr::core::array< T, TAlloc >::linear_search | ( | const T & | element | ) | const [inline] |
Finds an element in linear time, which is very slow.
Use binary_search for faster finding. Only works if ==operator is implemented.
element | Element to search for. |
Definition at line 506 of file irrArray.h.
Referenced by irr::core::array< IMesh * >::binary_search(), irr::scene::SMD3QuaternionTagList::get(), and irr::scene::quake3::SVarGroup::get().
bool irr::core::array< T, TAlloc >::operator!= | ( | const array< T, TAlloc > & | other | ) | const [inline] |
Inequality operator.
Definition at line 308 of file irrArray.h.
const array<T, TAlloc>& irr::core::array< T, TAlloc >::operator= | ( | const array< T, TAlloc > & | other | ) | [inline] |
Assignment operator.
Definition at line 267 of file irrArray.h.
bool irr::core::array< T, TAlloc >::operator== | ( | const array< T, TAlloc > & | other | ) | const [inline] |
Equality operator.
Definition at line 295 of file irrArray.h.
T& irr::core::array< T, TAlloc >::operator[] | ( | u32 | index | ) | [inline] |
Direct access operator.
Definition at line 315 of file irrArray.h.
const T& irr::core::array< T, TAlloc >::operator[] | ( | u32 | index | ) | const [inline] |
Direct const access operator.
Definition at line 324 of file irrArray.h.
T* irr::core::array< T, TAlloc >::pointer | ( | ) | [inline] |
Gets a pointer to the array.
Definition at line 352 of file irrArray.h.
Referenced by irr::scene::SSharedMeshBuffer::getIndices(), irr::scene::CMeshBuffer< T >::getIndices(), irr::scene::SSkinMeshBuffer::getIndices(), irr::scene::CMeshBuffer< T >::getVertices(), irr::scene::SSharedMeshBuffer::getVertices(), and irr::scene::SSkinMeshBuffer::getVertices().
void irr::core::array< T, TAlloc >::push_back | ( | const T & | element | ) | [inline] |
Adds an element at back of array.
If the array is too small to add this new element it is made bigger.
element,: | Element to add at the back of the array. |
Definition at line 112 of file irrArray.h.
Referenced by irr::scene::SAnimatedMesh::addMesh(), irr::scene::SMesh::addMeshBuffer(), irr::scene::CMeshBuffer< T >::append(), irr::scene::SSkinMeshBuffer::convertTo2TCoords(), irr::scene::SSkinMeshBuffer::convertToTangents(), irr::scene::quake3::getAsStringList(), irr::scene::quake3::getTextures(), irr::scene::SMD3QuaternionTagList::push_back(), irr::scene::quake3::SVarGroup::set(), irr::scene::SMD3QuaternionTagList::set_used(), and irr::core::string< fschar_t >::split().
void irr::core::array< T, TAlloc >::push_front | ( | const T & | element | ) | [inline] |
Adds an element at the front of the array.
If the array is to small to add this new element, the array is made bigger. Please note that this is slow, because the whole array needs to be copied for this.
element | Element to add at the back of the array. |
Definition at line 123 of file irrArray.h.
void irr::core::array< T, TAlloc >::reallocate | ( | u32 | new_size, |
bool | canShrink = true |
||
) | [inline] |
Reallocates the array, make it bigger or smaller.
new_size | New size of array. |
canShrink | Specifies whether the array is reallocated even if enough space is available. Setting this flag to false can speed up array usage, but may use more memory than required by the data. |
Definition at line 67 of file irrArray.h.
Referenced by irr::scene::CMeshBuffer< T >::append(), irr::core::array< IMesh * >::array(), irr::core::array< IMesh * >::insert(), and irr::core::array< IMesh * >::set_used().
void irr::core::array< T, TAlloc >::set_free_when_destroyed | ( | bool | f | ) | [inline] |
Sets if the array should delete the memory it uses upon destruction.
Also clear and set_pointer will only delete the (original) memory area if this flag is set to true, which is also the default. The methods reallocate, set_used, push_back, push_front, insert, and erase will still try to deallocate the original memory, which might cause troubles depending on the intended use of the memory area.
f | If true, the array frees the allocated memory in its destructor, otherwise not. The default is true. |
Definition at line 247 of file irrArray.h.
void irr::core::array< T, TAlloc >::set_pointer | ( | T * | newPointer, |
u32 | size, | ||
bool | _is_sorted = false , |
||
bool | _free_when_destroyed = true |
||
) | [inline] |
Sets pointer to new array, using this as new workspace.
Make sure that set_free_when_destroyed is used properly.
newPointer,: | Pointer to new array of elements. |
size,: | Size of the new array. |
_is_sorted | Flag which tells whether the new array is already sorted. |
_free_when_destroyed | Sets whether the new memory area shall be freed by the array upon destruction, or if this will be up to the user application. |
Definition at line 228 of file irrArray.h.
void irr::core::array< T, TAlloc >::set_sorted | ( | bool | _is_sorted | ) | [inline] |
Sets if the array is sorted.
Definition at line 584 of file irrArray.h.
void irr::core::array< T, TAlloc >::set_used | ( | u32 | usedNow | ) | [inline] |
Sets the size of the array and allocates new elements if necessary.
Please note: This is only secure when using it with simple types, because no default constructor will be called for the added elements.
usedNow | Amount of elements now used. |
Definition at line 257 of file irrArray.h.
void irr::core::array< T, TAlloc >::setAllocStrategy | ( | eAllocStrategy | newStrategy = ALLOC_STRATEGY_DOUBLE | ) | [inline] |
set a new allocation strategy
if the maximum size of the array is unknown, you can define how big the allocation should happen.
newStrategy | New strategy to apply to this array. |
Definition at line 103 of file irrArray.h.
Referenced by irr::scene::SMD3QuaternionTagList::SMD3QuaternionTagList(), irr::scene::quake3::SVarGroup::SVarGroup(), and irr::scene::quake3::SVarGroupList::SVarGroupList().
u32 irr::core::array< T, TAlloc >::size | ( | ) | const [inline] |
Get number of occupied elements of the array.
Definition at line 368 of file irrArray.h.
Referenced by irr::scene::SMesh::clear(), irr::scene::SSkinMeshBuffer::convertTo2TCoords(), irr::scene::SSkinMeshBuffer::convertToTangents(), irr::scene::quake3::dumpShader(), irr::scene::quake3::dumpVarGroup(), irr::scene::quake3::getAsStringList(), irr::scene::SAnimatedMesh::getFrameCount(), irr::scene::quake3::IShader::getGroup(), irr::scene::quake3::IShader::getGroupSize(), irr::scene::SSharedMeshBuffer::getIndexCount(), irr::scene::CMeshBuffer< T >::getIndexCount(), irr::scene::SSkinMeshBuffer::getIndexCount(), irr::scene::SMesh::getMeshBuffer(), irr::scene::SMesh::getMeshBufferCount(), irr::scene::quake3::getTextures(), irr::scene::CMeshBuffer< T >::getVertexCount(), irr::scene::SSharedMeshBuffer::getVertexCount(), irr::scene::SSkinMeshBuffer::getVertexCount(), irr::scene::quake3::SVarGroup::isDefined(), irr::scene::SMesh::recalculateBoundingBox(), irr::scene::SAnimatedMesh::recalculateBoundingBox(), irr::scene::SSharedMeshBuffer::recalculateBoundingBox(), irr::scene::CMeshBuffer< T >::recalculateBoundingBox(), irr::scene::SSkinMeshBuffer::recalculateBoundingBox(), irr::core::array< IMesh * >::set_pointer(), irr::scene::SMesh::setDirty(), irr::scene::SAnimatedMesh::setDirty(), irr::scene::SMesh::setHardwareMappingHint(), irr::scene::SAnimatedMesh::setHardwareMappingHint(), irr::scene::SMesh::setMaterialFlag(), irr::scene::SAnimatedMesh::setMaterialFlag(), irr::scene::SMD3QuaternionTagList::size(), irr::scene::SAnimatedMesh::~SAnimatedMesh(), irr::scene::SMD3Mesh::~SMD3Mesh(), and irr::scene::SMesh::~SMesh().
void irr::core::array< T, TAlloc >::sort | ( | ) | [inline] |
Sorts the array using heapsort.
There is no additional memory waste and the algorithm performs O(n*log n) in worst case.
Definition at line 394 of file irrArray.h.
Referenced by irr::core::array< IMesh * >::binary_search(), and irr::core::array< IMesh * >::binary_search_multi().
void irr::core::array< T, TAlloc >::swap | ( | array< T, TAlloc > & | other | ) | [inline] |
Swap the content of this array container with the content of another array.
Afterwards this object will contain the content of the other object and the other object will contain the content of this object.
other | Swap content with this object |
Definition at line 594 of file irrArray.h.
Referenced by irr::core::array< IMesh * >::swap().