diff options
-rw-r--r-- | CommonLibs/Vector.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h index 38dc8d5..7062e17 100644 --- a/CommonLibs/Vector.h +++ b/CommonLibs/Vector.h @@ -222,6 +222,21 @@ template <class T> class Vector { memcpy(other.mStart,base,span*sizeof(T)); } + /** + Move (copy) a segment of this vector into a different position in the vector + @param from Start point from which to copy. + @param to Start point to which to copy. + @param span The number of elements to copy. + */ + void segmentMove(size_t from, size_t to, size_t span) + { + const T* baseFrom = mStart + from; + T* baseTo = mStart + to; + assert(baseFrom+span<=mEnd); + assert(baseTo+span<=mEnd); + memmove(baseTo,baseFrom,span*sizeof(T)); + } + void fill(const T& val) { T* dp=mStart; |