So, i want to create a wall system, i need to be able to add segments to an array, but i don't want to pre allocate crazy memory, how do i work with this?
I create a new array which is one element bigger, copy everything from the older one, and put the new data in the empty slot, and then remove the old one from memory?
@YoSoyFreeman The way that it's commonly done (and how most List<T> type structures work under-the-hood) is that it starts out with a reasonable default capacity (say, 16) and tracks its count separately from its capacity. Then, whenever it needs to expand (count > capacity), it doubles capacity, and copies everything over to the new doubled space.
That minimizes the amount of churn while still allowing for expansion.
@YoSoyFreeman Once you've copied over the data and freed the old memory, yes.