| 1064 | |
| 1065 | template<typename T> |
| 1066 | void Vector<T>::resize(size_t newCount, bool freeMemory) |
| 1067 | { |
| 1068 | size_t newCapacity = m_Capacity; |
| 1069 | if (newCount > m_Capacity) |
| 1070 | { |
| 1071 | newCapacity = D3D12MA_MAX(newCount, D3D12MA_MAX(m_Capacity * 3 / 2, (size_t)8)); |
| 1072 | } |
| 1073 | else if (freeMemory) |
| 1074 | { |
| 1075 | newCapacity = newCount; |
| 1076 | } |
| 1077 | |
| 1078 | if (newCapacity != m_Capacity) |
| 1079 | { |
| 1080 | T* const newArray = newCapacity ? AllocateArray<T>(m_AllocationCallbacks, newCapacity) : NULL; |
| 1081 | const size_t elementsToCopy = D3D12MA_MIN(m_Count, newCount); |
| 1082 | if (elementsToCopy != 0) |
| 1083 | { |
| 1084 | memcpy(newArray, m_pArray, elementsToCopy * sizeof(T)); |
| 1085 | } |
| 1086 | Free(m_AllocationCallbacks, m_pArray); |
| 1087 | m_Capacity = newCapacity; |
| 1088 | m_pArray = newArray; |
| 1089 | } |
| 1090 | |
| 1091 | m_Count = newCount; |
| 1092 | } |
| 1093 | |
| 1094 | template<typename T> |
| 1095 | void Vector<T>::insert(size_t index, const T& src) |
no test coverage detected