Dynamic array, InsertRange implementation
Hey guys I'm having a mental block.
I want to implement an InsertRange() function, on my array class, and I'm having trouble figuring out how to implement it. (needs to work like std::vector)
Code:
void InsertRange(int index, T* data, int count)
{
}
So this is what I'm thinking....
Check if there is enough space, if not, create new array (of T) with (capacity * 2),
copy old data upto index into new array, insert the given data, copy old data
above index.
Else move everything above (index + count), by count, then insert given data.
Is that right?