Assimp
v4.1. (December 2018)
|
Self reallocating template array (like stl vector) with additional features. More...
Public Member Functions | |
u32 | allocated_size () const |
Returns amount memory allocated. More... | |
array () | |
array (const array< T > &other) | |
Copy constructor. More... | |
array (u32 start_count) | |
Constructs a array and allocates an initial chunk of memory. More... | |
s32 | binary_search (const T &element) |
Performs a binary search for an element, returns -1 if not found. More... | |
s32 | binary_search (const T &element, s32 left, s32 right) |
Performs a binary search for an element, returns -1 if not found. More... | |
void | clear () |
Clears the array and deletes all allocated memory. More... | |
const T * | const_pointer () const |
Returns a const pointer to the array. More... | |
bool | empty () const |
Returns true if array is empty. More... | |
void | erase (u32 index) |
Erases an element from the array. More... | |
void | erase (u32 index, s32 count) |
Erases some elements from the array. More... | |
T & | getLast () |
Gets last frame. More... | |
const T & | getLast () const |
Gets last frame. More... | |
void | insert (const T &element, u32 index=0) |
Insert item into array at specified position. More... | |
s32 | linear_reverse_search (T &element) |
Finds an element in linear time, which is very slow. More... | |
s32 | linear_search (T &element) |
Finds an element in linear time, which is very slow. More... | |
void | operator= (const array< T > &other) |
Assignement operator. More... | |
T & | operator[] (u32 index) |
Direct access operator. More... | |
const T & | operator[] (u32 index) const |
Direct access operator. More... | |
T * | pointer () |
Returns a pointer to the array. More... | |
void | push_back (const T &element) |
Adds an element at back of array. More... | |
void | push_front (const T &element) |
Adds an element at the front of the array. More... | |
void | reallocate (u32 new_size) |
Reallocates the array, make it bigger or smaller. More... | |
void | set_free_when_destroyed (bool f) |
Sets if the array should delete the memory it used. More... | |
void | set_pointer (T *newPointer, u32 size) |
Sets pointer to new array, using this as new workspace. More... | |
void | set_sorted (bool _is_sorted) |
Sets if the array is sorted. More... | |
void | set_used (u32 usedNow) |
Sets the size of the array. More... | |
u32 | size () const |
Returns size of used array. More... | |
void | sort () |
Sorts the array using heapsort. More... | |
~array () | |
Destructor. More... | |
Self reallocating template array (like stl vector) with additional features.
Some features are: Heap sorting, binary search methods, easier debugging.
|
inline |
|
inline |
Constructs a array and allocates an initial chunk of memory.
start_count | Amount of elements to allocate. |
|
inline |
Copy constructor.
|
inline |
Destructor.
Frees allocated memory, if set_free_when_destroyed was not set to false by the user before.
|
inline |
Returns amount memory allocated.
|
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.
element | Element to search for. |
|
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.
element | Element to search for. |
left | First left index |
right | Last right index. |
|
inline |
Clears the array and deletes all allocated memory.
|
inline |
Returns a const pointer to the array.
|
inline |
Returns true if array is empty.
|
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. |
|
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. |
|
inline |
Gets last frame.
|
inline |
Gets last frame.
|
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. |
|
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. |
|
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. |
|
inline |
Assignement operator.
|
inline |
Direct access operator.
|
inline |
Direct access operator.
|
inline |
Returns a pointer to the array.
|
inline |
Adds an element at back of array.
If the array is to small to add this new element, the array is made bigger.
element | Element to add at the back of the array. |
|
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. |
|
inline |
Reallocates the array, make it bigger or smaller.
new_size | New size of array. |
|
inline |
Sets if the array should delete the memory it used.
f | If true, the array frees the allocated memory in its destructor, otherwise not. The default is true. |
|
inline |
Sets pointer to new array, using this as new workspace.
newPointer | Pointer to new array of elements. |
size | Size of the new array. |
|
inline |
Sets if the array is sorted.
|
inline |
Sets the size of the array.
usedNow | Amount of elements now used. |
|
inline |
Returns size of used array.
|
inline |
Sorts the array using heapsort.
There is no additional memory waste and the algorithm performs (O) n log n in worst case.