MCPcopy Create free account
hub / github.com/adriancable/eternal / Insert

Method Insert

doom/src/tarray.h:298–319  ·  view source on GitHub ↗

Inserts an item into the array, shifting elements as needed

Source from the content-addressed store, hash-verified

296
297 // Inserts an item into the array, shifting elements as needed
298 void Insert (unsigned int index, const T &item)
299 {
300 if (index >= Count)
301 {
302 // Inserting somewhere past the end of the array, so we can
303 // just add it without moving things.
304 Resize (index + 1);
305 ::new ((void *)&Array[index]) T(item);
306 }
307 else
308 {
309 // Inserting somewhere in the middle of the array,
310 // so make room for it
311 Resize (Count + 1);
312
313 // Now move items from the index and onward out of the way
314 memmove (&Array[index+1], &Array[index], sizeof(T)*(Count - index - 1));
315
316 // And put the new element in
317 ::new ((void *)&Array[index]) T(item);
318 }
319 }
320 void ShrinkToFit ()
321 {
322 if (Most > Count)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected