diff options
author | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2017-03-18 14:08:43 -0700 |
---|---|---|
committer | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2017-03-24 01:25:06 +0000 |
commit | f0189c47beb4ccfbbbb805d324d2b7bcb1092653 (patch) | |
tree | 9a25584b407fa8a5e4eccc4ab24b66594c639bca | |
parent | c708816be111b872f1793d48f04d5d926847dec2 (diff) |
vector: Introduce shrink() function to shrink vector size without loosing data.
Change-Id: I9c0ac2715aea1a90c9e6ebcd982522b80a547099
-rw-r--r-- | CommonLibs/Vector.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h index 7062e17..eae674b 100644 --- a/CommonLibs/Vector.h +++ b/CommonLibs/Vector.h @@ -92,6 +92,13 @@ template <class T> class Vector { mEnd = mStart + newSize; } + /** Reduce addressable size of the Vector, keeping content. */ + void shrink(size_t newSize) + { + assert(newSize <= mEnd - mStart); + mEnd = mStart + newSize; + } + /** Release memory and clear pointers. */ void clear() { resize(0); } |