[PATCH] osmo-trx[master]: vector: Introduce segmentMove() method to move data inside o...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Alexander Chemeris gerrit-no-reply at lists.osmocom.org
Wed Mar 22 18:44:20 UTC 2017


Review at  https://gerrit.osmocom.org/2156

vector: Introduce segmentMove() method to move data inside of a vector.

Change-Id: I2f3f4267b4137a0bc031f27e0f896fba9b9f3433
---
M CommonLibs/Vector.h
1 file changed, 15 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/56/2156/1

diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h
index 38dc8d5..bb4d352 100644
--- a/CommonLibs/Vector.h
+++ b/CommonLibs/Vector.h
@@ -222,6 +222,21 @@
 		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
+	{
+		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;

-- 
To view, visit https://gerrit.osmocom.org/2156
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f3f4267b4137a0bc031f27e0f896fba9b9f3433
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Alexander Chemeris <Alexander.Chemeris at gmail.com>



More information about the gerrit-log mailing list