///////////////////////////////////////////////////////////////////// ! Resize array \param compaction If set to true and the specified size is smaller than the capacity, a new memory block which fits the size is allocated and the old one gets freed. */ /////////////////////////////////////////////////////////////////////
| 973 | */ |
| 974 | ////////////////////////////////////////////////////////////////////////// |
| 975 | NX_INLINE void resize(const NxU32 size, const bool compaction = false, const T& a = T()) |
| 976 | { |
| 977 | if(size > mCapacity) |
| 978 | { |
| 979 | grow(size); |
| 980 | } |
| 981 | else if (compaction && (size != mCapacity)) |
| 982 | { |
| 983 | recreate(size, NxMin(mSize, size)); |
| 984 | } |
| 985 | |
| 986 | for(NxU32 i = mSize; i < size; i++) |
| 987 | ::new(mData+i)T(a); |
| 988 | |
| 989 | if (!compaction) // With compaction, these elements have been deleted already |
| 990 | { |
| 991 | for(NxU32 i = size; i < mSize; i++) |
| 992 | mData[i].~T(); |
| 993 | } |
| 994 | |
| 995 | mSize = size; |
| 996 | } |
| 997 | |
| 998 | |
| 999 | ////////////////////////////////////////////////////////////////////////// |
no test coverage detected