I am a beginner, and I want to delete an item from an array, non-STL.
This doesn't seem possible? Below. So, out of share curiosity, how can I delete or remove an item from a regular array, I am not using STL. I want to know how this can be done with one dynamic array that's been allocated on the HEAP.
If the ordering is not important, find the index of the item to be deleted, swap it with the last element and decrement the item count. This is the fastest method and it's performance doesn't depend upon how many items in the dynamic array.
If the ordering is important, find the index of the item to be deleted, shuffle all elements after this down one to overwrite the item to be deleted and decrement the item count. This is the slowest method and performance depends upon how many items exist after the item to be deleted.
If the ordering is not important, find the index of the item to be deleted, swap it with the last element and decrement the item count. This is the fastest method and it's performance doesn't depend upon how many items in the dynamic array.
If the ordering is important, find the index of the item to be deleted, shuffle all elements after this down one to overwrite the item to be deleted and decrement the item count. This is the slowest method and performance depends upon how many items exist after the item to be deleted.