Inserts an item into the array, shifting elements as needed
| 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) |
nothing calls this directly
no outgoing calls
no test coverage detected