a new method in "irrArray.h" for the array class:
Code: Select all
//! erase the array from "index" to "end" if option=false
/**erase the array from "index to "start" if option=true,*/
void erase(u32 index, bool option ) //no default value for "option"
{
//check if was entered an invalid value
if(index >= used)
return;
u32 i=0;
if(option)
{
for (; i<index; ++i)
allocator.destruct(&data[i]);
for (i=0; i<(used-index); ++i)
allocator.construct(&data[i], data[i+index]);
for (; i<used; ++i)
allocator.destruct(&data[i]);
used-=index;
}
else
{
for (i=index; i<used; ++i)
allocator.destruct(&data[i]);
used=index;
}
}
This method is only optimized for deleting the array from "start to index" or from "index to end" (the latest one is the fastest).
I'm actually using it in my game. If this is not suitable for the engine itself I will put that code in code snippets.
(i'm testing it, but if someone can tell me that it is correct I'm happy twice)