Added comment for Deque copy ctor

This commit is contained in:
sfc-gh-tclinkenbeard 2020-06-11 08:44:02 -07:00
parent c2587bd87c
commit 4376f441f7
1 changed files with 6 additions and 0 deletions

View File

@ -50,6 +50,9 @@ public:
if (r.end < r.capacity()) {
std::copy(r.arr + r.begin, r.arr + r.begin + r.size(), arr);
} else {
// Mask is used for wrapping, so r.end is always >= r.begin,
// but if r.end >= r.capacity(), the deque wraps around so the
// copy must be performed in two parts
auto partOneSize = r.capacity() - r.begin;
std::copy(r.arr + r.begin, r.arr + r.begin + partOneSize, arr);
std::copy(r.arr, r.arr + (r.end & r.mask), arr + partOneSize);
@ -71,6 +74,9 @@ public:
if (r.end < r.capacity()) {
std::copy(r.arr + r.begin, r.arr + r.begin + r.size(), arr);
} else {
// Mask is used for wrapping, so r.end is always >= r.begin,
// but if r.end >= r.capacity(), the deque wraps around so the
// copy must be performed in two parts
auto partOneSize = r.capacity() - r.begin;
std::copy(r.arr + r.begin, r.arr + r.begin + partOneSize, arr);
std::copy(r.arr, r.arr + (r.end & r.mask), arr + partOneSize);