8#ifndef INCLUDED_BSLALG_DEQUEPRIMITIVES
9#define INCLUDED_BSLALG_DEQUEPRIMITIVES
160#include <bslscm_version.h>
187#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
193# define COMPILING_BSLALG_DEQUEPRIMITIVES_H
195# undef COMPILING_BSLALG_DEQUEPRIMITIVES_H
204template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
205class DequePrimitives_DequeElementGuard;
207template <
class VALUE_TYPE,
int BLOCK_LENGTH>
208class DequePrimitives_DequeMoveGuard;
210template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
211class DequePrimitives_ExternalDequeElementGuard;
213template <
class VALUE_TYPE,
int BLOCK_LENGTH>
214class DequePrimitives_DequeEndpointProctor;
240template <
class VALUE_TYPE,
int BLOCK_LENGTH>
264 template <
class ALLOCATOR>
276 template <
class ALLOCATOR>
282 template <
class ALLOCATOR>
300 template <
class ALLOCATOR>
307 ALLOCATOR allocator);
321 template <
class ALLOCATOR>
331 template <
class ALLOCATOR>
353 template <
class ALLOCATOR>
358 const VALUE_TYPE& value,
359 ALLOCATOR allocator);
373 template <
class ALLOCATOR>
379 const VALUE_TYPE& value,
384 template <
class ALLOCATOR>
390 const VALUE_TYPE& value,
395 template <
class ALLOCATOR>
401 const VALUE_TYPE& value,
415 template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
422 ALLOCATOR allocator);
433 template <
class ALLOCATOR>
439 ALLOCATOR allocator);
452 template <
class ALLOCATOR>
462 template <
class ALLOCATOR>
472 template <
class ALLOCATOR>
491 template <
class ALLOCATOR>
496 const VALUE_TYPE& value,
497 ALLOCATOR allocator);
511 template <
class ALLOCATOR>
517 const VALUE_TYPE& value,
522 template <
class ALLOCATOR>
528 const VALUE_TYPE& value,
533 template <
class ALLOCATOR>
539 const VALUE_TYPE& value,
553 template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
560 ALLOCATOR allocator);
572 template <
class ALLOCATOR>
578 ALLOCATOR allocator);
592 template <
class ALLOCATOR>
602 template <
class ALLOCATOR>
612 template <
class ALLOCATOR>
621#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
632 template <
class ALLOCATOR,
class... Args>
637 Args&&... arguments);
652 template <
class ALLOCATOR,
class... Args>
660 Args&&... arguments);
661 template <
class ALLOCATOR,
class... Args>
669 Args&&... arguments);
670 template <
class ALLOCATOR,
class... Args>
677 Args&&... arguments);
690 template <
class ALLOCATOR,
class... Args>
695 Args&&... arguments);
710 template <
class ALLOCATOR,
class... Args>
718 Args&&... arguments);
719 template <
class ALLOCATOR,
class... Args>
727 Args&&... arguments);
728 template <
class ALLOCATOR,
class... Args>
735 Args&&... arguments);
767 template <
class ALLOCATOR>
771 const VALUE_TYPE& value,
772 ALLOCATOR allocator);
783 template <
class ALLOCATOR>
787 const VALUE_TYPE& value,
788 ALLOCATOR allocator);
799 template <
class ALLOCATOR>
803 ALLOCATOR allocator);
810template <
class VALUE_TYPE>
819 template <
class ALLOCATOR>
822 template <
class ALLOCATOR>
829 ALLOCATOR allocator);
831 template <
class ALLOCATOR>
836 const VALUE_TYPE& value,
837 ALLOCATOR allocator);
839 template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
846 ALLOCATOR allocator);
848 template <
class ALLOCATOR>
853 const VALUE_TYPE& value,
854 ALLOCATOR allocator);
856 template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
863 ALLOCATOR allocator);
865 template <
class ALLOCATOR>
869 const VALUE_TYPE& value,
870 ALLOCATOR allocator);
871 template <
class ALLOCATOR>
876 const VALUE_TYPE& value,
880 template <
class ALLOCATOR>
885 const VALUE_TYPE& value,
889 template <
class ALLOCATOR>
893 const VALUE_TYPE& value,
894 ALLOCATOR allocator);
895 template <
class ALLOCATOR>
900 const VALUE_TYPE& value,
903 template <
class ALLOCATOR>
908 const VALUE_TYPE& value,
912 template <
class ALLOCATOR>
916 ALLOCATOR allocator);
918 template <
class ALLOCATOR>
926 template <
class ALLOCATOR>
946template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
957 ALLOCATOR d_allocator;
977 ALLOCATOR allocator);
1014template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
1028 ALLOCATOR d_allocator;
1048 ALLOCATOR allocator);
1073template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1127template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1178template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1179template <
class ALLOCATOR>
1183 ALLOCATOR allocator)
1188 VALUE = IS_BITWISECOPYABLE
1193 return destruct(begin,
1199template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1200template <
class ALLOCATOR>
1210template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1211template <
class ALLOCATOR>
1215 ALLOCATOR allocator,
1218 for (; !(begin == end); ++begin) {
1224template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1225template <
class ALLOCATOR>
1235 ALLOCATOR allocator)
1240 VALUE = IS_BITWISECOPYABLE
1245 return erase(toBegin,
1255template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1256template <
class ALLOCATOR>
1265 ALLOCATOR allocator,
1268 if (first == last) {
1269 *toBegin = fromBegin;
1274 size_type frontSize = first - fromBegin;
1278 if (frontSize < backSize) {
1280 for (; 0 < frontSize; --frontSize) {
1283 *last = MoveUtil::move(*first);
1290 for (; 0 < backSize; --backSize, ++first, ++last) {
1291 *first = MoveUtil::move(*last);
1293 *toBegin = fromBegin;
1296 destruct(first, last, allocator);
1300template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1301template <
class ALLOCATOR>
1314 size_type frontSize = first - fromBegin;
1318 if (frontSize < backSize) {
1320 moveBack(&last, &first, frontSize);
1326 moveFront(&first, &last, backSize);
1327 *toBegin = fromBegin;
1334template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1335template <
class ALLOCATOR>
1343 const VALUE_TYPE& value,
1344 ALLOCATOR allocator)
1350 VALUE = IS_BITWISECOPYABLE
1352 : IS_BITWISEMOVEABLE
1357 insertAndMoveToBack(toEnd,
1366template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1367template <
class ALLOCATOR>
1373 const VALUE_TYPE& value,
1374 ALLOCATOR allocator,
1378 size_type backSize = fromEnd - position;
1398 moveBack(&dest, &end, backSize);
1399 uninitializedFillNFront(&dest, dest, numElements, space.
object(),
1402 *toEnd = fromEnd + numElements;
1405template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1406template <
class ALLOCATOR>
1412 const VALUE_TYPE& value,
1413 ALLOCATOR allocator,
1419 ALLOCATOR> ExtGuard;
1422 size_type backSize = fromEnd - position;
1443 MoveGuard guard(end, dest, backSize,
false);
1445 moveBack(&dest, &end, backSize);
1451 ExtGuard eguard(&dest, &dest2, allocator);
1453 uninitializedFillNFront(&dest, dest, numElements, space.
object(),
1457 *toEnd = fromEnd + numElements;
1460template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1461template <
class ALLOCATOR>
1467 const VALUE_TYPE& value,
1468 ALLOCATOR allocator,
1473 ALLOCATOR> ElementGuard;
1475 size_type backSize = fromEnd - position;
1495 ElementGuard guard(dest, dest, allocator);
1496 if (backSize >= numElements) {
1497 for (numDest = numElements; 0 < numDest; --numDest) {
1503 guard.moveBegin(-1);
1505 for (backSize -= numElements; 0 < backSize; --backSize) {
1510 for (numDest = numElements; 0 < numDest; --numDest, ++position) {
1511 *position = space.
object();
1514 for (numDest = backSize; 0 < numDest; --numDest) {
1520 guard.moveBegin(-1);
1522 for (numDest = numElements; backSize < numDest; --numDest) {
1528 guard.moveBegin(-1);
1530 for (; 0 < numDest; --numDest, ++position) {
1531 *position = space.
object();
1536 *toEnd = fromEnd + numElements;
1539template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1540template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
1549 ALLOCATOR allocator)
1553 ALLOCATOR> ElementGuard;
1555 size_type backSize = fromEnd - position;
1560 ElementGuard guard(dest, dest, allocator);
1561 if (backSize >= numElements) {
1562 for (numDest = numElements; 0 < numDest; --numDest) {
1568 guard.moveBegin(-1);
1570 for (numDest = backSize; numElements < numDest; --numDest) {
1575 for (; 0 < numDest; ++first, ++position, --numDest) {
1579 for (numDest = backSize; 0 < numDest; --numDest) {
1585 guard.moveBegin(-1);
1587 for (numDest = backSize; 0 < numDest; --numDest, ++position, ++first) {
1591 ElementGuard guard2(position, position, allocator);
1592 for (numDest = numElements; backSize < numDest; ++first, ++position,
1595 position.valuePtr(),
1602 *toEnd = fromEnd + numElements;
1605template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1606template <
class ALLOCATOR>
1614 ALLOCATOR allocator)
1620 VALUE = IS_BITWISECOPYABLE
1622 : IS_BITWISEMOVEABLE
1627 VALUE_TYPE& lvalue = value;
1629 moveInsertAndMoveToBack(toEnd,
1632 MoveUtil::move(lvalue),
1637template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1638template <
class ALLOCATOR>
1644 ALLOCATOR allocator,
1648 const size_type backSize = fromEnd - position;
1655 moveBack(&dest, &end, backSize);
1658 VALUE_TYPE& lvalue = value;
1661 MoveUtil::move(lvalue));
1663 *toEnd = fromEnd + 1;
1666template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1667template <
class ALLOCATOR>
1673 ALLOCATOR allocator,
1677 const size_type backSize = fromEnd - position;
1684 MoveGuard guard(end, dest, backSize,
false);
1686 moveBack(&dest, &end, backSize);
1689 VALUE_TYPE& lvalue = value;
1692 MoveUtil::move(lvalue));
1696 *toEnd = fromEnd + 1;
1699template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1700template <
class ALLOCATOR>
1706 ALLOCATOR allocator,
1711 ALLOCATOR> ElementGuard;
1713 size_type backSize = fromEnd - position;
1719 ElementGuard guard(dest, dest, allocator);
1728 MoveUtil::move_if_noexcept(*end));
1729 guard.moveBegin(-1);
1733 for (backSize -= 1; 0 < backSize; --backSize) {
1736 *dest = MoveUtil::move_if_noexcept(*end);
1741 VALUE_TYPE& lvalue = value;
1742 *position = MoveUtil::move(lvalue);
1746 *toEnd = fromEnd + 1;
1749template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1750template <
class ALLOCATOR>
1758 const VALUE_TYPE& value,
1759 ALLOCATOR allocator)
1765 VALUE = IS_BITWISECOPYABLE
1767 : IS_BITWISEMOVEABLE
1772 insertAndMoveToFront(toBegin,
1781template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1782template <
class ALLOCATOR>
1788 const VALUE_TYPE& value,
1789 ALLOCATOR allocator,
1793 size_type frontSize = position - fromBegin;
1795 Iterator dest = begin - numElements;
1813 moveFront(&dest, &begin, frontSize);
1814 uninitializedFillNBack(&dest, dest, numElements, space.
object(),
1817 *toBegin = fromBegin - numElements;
1820template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1821template <
class ALLOCATOR>
1827 const VALUE_TYPE& value,
1828 ALLOCATOR allocator,
1834 ALLOCATOR> ExtGuard;
1835 size_type frontSize = position - fromBegin;
1837 Iterator dest = begin - numElements;
1855 MoveGuard guard(begin, dest, frontSize,
true);
1857 moveFront(&dest, &begin, frontSize);
1863 ExtGuard eguard(&dest2, &dest, allocator);
1865 uninitializedFillNBack(&dest, dest, numElements, space.
object(),
1870 *toBegin = fromBegin - numElements;
1873template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1874template <
class ALLOCATOR>
1880 const VALUE_TYPE& value,
1881 ALLOCATOR allocator,
1886 ALLOCATOR> ElementGuard;
1888 size_type frontSize = position - fromBegin;
1890 Iterator dest = begin - numElements;
1907 ElementGuard guard(dest, dest, allocator);
1908 if (frontSize >= numElements) {
1909 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
1915 for (frontSize -= numElements; 0 < frontSize;
1916 --frontSize, ++dest, ++begin) {
1919 for (numDest = numElements; 0 < numDest; --numDest, ++dest) {
1923 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
1929 for (numDest = numElements; frontSize < numDest; --numDest, ++dest) {
1935 for (; 0 < numDest; --numDest, ++dest) {
1940 *toBegin = fromBegin - numElements;
1943template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1944template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
1953 ALLOCATOR allocator)
1957 ALLOCATOR> ElementGuard;
1959 size_type frontSize = position - fromBegin;
1961 Iterator dest = begin - numElements;
1964 ElementGuard guard(dest, dest, allocator);
1965 if (frontSize >= numElements) {
1966 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
1972 for (frontSize -= numElements; 0 < frontSize;
1973 --frontSize, ++dest, ++begin) {
1976 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++first) {
1980 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
1986 for (numDest = numElements; frontSize < numDest;
1987 --numDest, ++dest, ++first) {
1993 for (; 0 < numDest; --numDest, ++dest, ++first) {
1998 *toBegin = fromBegin - numElements;
2001template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2002template <
class ALLOCATOR>
2010 ALLOCATOR allocator)
2016 VALUE = IS_BITWISECOPYABLE
2018 : IS_BITWISEMOVEABLE
2023 VALUE_TYPE& lvalue = value;
2025 moveInsertAndMoveToFront(toBegin,
2028 MoveUtil::move(lvalue),
2033template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2034template <
class ALLOCATOR>
2040 ALLOCATOR allocator,
2044 const size_type frontSize = position - fromBegin;
2051 moveFront(&dest, &begin, frontSize);
2053 VALUE_TYPE& lvalue = value;
2056 MoveUtil::move(lvalue));
2058 *toBegin = fromBegin - 1;
2061template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2062template <
class ALLOCATOR>
2068 ALLOCATOR allocator,
2072 const size_type frontSize = position - fromBegin;
2079 MoveGuard guard(begin, dest, frontSize,
true);
2081 moveFront(&dest, &begin, frontSize);
2083 VALUE_TYPE& lvalue = value;
2086 MoveUtil::move(lvalue));
2090 *toBegin = fromBegin - 1;
2093template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2094template <
class ALLOCATOR>
2100 ALLOCATOR allocator,
2105 ALLOCATOR> ElementGuard;
2107 size_type frontSize = position - fromBegin;
2113 ElementGuard guard(dest, dest, allocator);
2120 MoveUtil::move_if_noexcept(*begin));
2127 for (frontSize -= 1; 0 < frontSize; --frontSize, ++dest, ++begin) {
2128 *dest = MoveUtil::move_if_noexcept(*begin);
2133 VALUE_TYPE& lvalue = value;
2134 *dest = MoveUtil::move(lvalue);
2138 *toBegin = fromBegin - 1;
2141#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2142template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2143template <
class ALLOCATOR,
class... Args>
2150 ALLOCATOR allocator,
2151 Args&&... arguments)
2157 VALUE = IS_BITWISECOPYABLE
2159 : IS_BITWISEMOVEABLE
2164 emplaceAndMoveToBackDispatch(
2173template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2174template <
class ALLOCATOR,
class... Args>
2179 ALLOCATOR allocator,
2182 Args&&... arguments)
2184 const size_type backSize = fromEnd - position;
2191 moveBack(&dest, &end, backSize);
2199 *toEnd = fromEnd + 1;
2202template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2203template <
class ALLOCATOR,
class... Args>
2208 ALLOCATOR allocator,
2211 Args&&... arguments)
2213 const size_type backSize = fromEnd - position;
2220 MoveGuard guard(end, dest, backSize,
false);
2222 moveBack(&dest, &end, backSize);
2232 *toEnd = fromEnd + 1;
2235template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2236template <
class ALLOCATOR,
class... Args>
2241 ALLOCATOR allocator,
2243 Args&&... arguments)
2247 ALLOCATOR> ElementGuard;
2250 BLOCK_LENGTH> EndpointProctor;
2252 size_type backSize = fromEnd - position;
2258 ElementGuard guard(dest, dest, allocator);
2267 MoveUtil::move_if_noexcept(*end));
2268 guard.moveBegin(-1);
2273 for (backSize -= 1; 0 < backSize; --backSize) {
2276 *dest = MoveUtil::move_if_noexcept(*end);
2279 guard.moveBegin(-n);
2290 EndpointProctor endpointProctor(toEnd, position);
2297 endpointProctor.release();
2300 *toEnd = fromEnd + 1;
2303template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2304template <
class ALLOCATOR,
class... Args>
2311 ALLOCATOR allocator,
2312 Args&&... arguments)
2318 VALUE = IS_BITWISECOPYABLE
2320 : IS_BITWISEMOVEABLE
2325 emplaceAndMoveToFrontDispatch(
2334template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2335template <
class ALLOCATOR,
class... Args>
2340 ALLOCATOR allocator,
2343 Args&&... arguments)
2345 const size_type frontSize = position - fromBegin;
2352 moveFront(&dest, &begin, frontSize);
2359 *toBegin = fromBegin - 1;
2362template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2363template <
class ALLOCATOR,
class... Args>
2368 ALLOCATOR allocator,
2371 Args&&... arguments)
2373 const size_type frontSize = position - fromBegin;
2380 MoveGuard guard(begin, dest, frontSize,
true);
2382 moveFront(&dest, &begin, frontSize);
2391 *toBegin = fromBegin - 1;
2394template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2395template <
class ALLOCATOR,
class... Args>
2400 ALLOCATOR allocator,
2402 Args&&... arguments)
2406 ALLOCATOR> ElementGuard;
2409 BLOCK_LENGTH> EndpointProctor;
2411 size_type frontSize = position - fromBegin;
2417 ElementGuard guard(dest, dest, allocator);
2424 MoveUtil::move_if_noexcept(*begin));
2432 for (frontSize -= 1; 0 < frontSize; --frontSize, ++dest, ++begin) {
2433 *dest = MoveUtil::move_if_noexcept(*begin);
2447 EndpointProctor endpointProctor(toBegin, position);
2454 endpointProctor.release();
2457 *toBegin = fromBegin - 1;
2461template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2471 *destination -= numElements;
2472 *source -= numElements;
2473 std::memmove((
void *)destination->
valuePtr(),
2475 numElements *
sizeof(VALUE_TYPE));
2537 secondSegment = destination->
offsetInBlock() - firstSegment;
2540 size_type thirdSegment = BLOCK_LENGTH - secondSegment;
2542 *destination -= firstSegment;
2543 *source -= firstSegment;
2544 numElements -= firstSegment;
2546 std::memmove((
void *)destination->
valuePtr(),
2548 firstSegment *
sizeof(VALUE_TYPE));
2550 for (; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2552 *destination -= secondSegment;
2553 *source -= secondSegment;
2555 std::memmove((
void *)destination->
valuePtr(),
2557 secondSegment *
sizeof(VALUE_TYPE));
2559 *destination -= thirdSegment;
2560 *source -= thirdSegment;
2562 std::memmove((
void *)destination->
valuePtr(),
2564 thirdSegment *
sizeof(VALUE_TYPE));
2567 size_type remaining = numElements > secondSegment
2571 *destination -= remaining;
2572 *source -= remaining;
2573 numElements -= remaining;
2575 std::memmove((
void *)destination->
valuePtr(),
2577 remaining *
sizeof(VALUE_TYPE));
2579 *destination -= numElements;
2580 *source -= numElements;
2582 std::memmove((
void *)destination->
valuePtr(),
2584 numElements *
sizeof(VALUE_TYPE));
2587template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2597 std::memmove((
void *)destination->
valuePtr(),
2599 numElements *
sizeof(VALUE_TYPE));
2600 *destination += numElements;
2601 *source += numElements;
2666 size_type thirdSegment = BLOCK_LENGTH - secondSegment;
2668 std::memmove((
void *)destination->
valuePtr(),
2670 firstSegment *
sizeof(VALUE_TYPE));
2672 *destination += firstSegment;
2673 *source += firstSegment;
2674 numElements -= firstSegment;
2676 for (; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2678 std::memmove((
void *)destination->
valuePtr(),
2680 secondSegment *
sizeof(VALUE_TYPE));
2682 *destination += secondSegment;
2683 *source += secondSegment;
2685 std::memmove((
void *)destination->
valuePtr(),
2687 thirdSegment *
sizeof(VALUE_TYPE));
2689 *destination += thirdSegment;
2690 *source += thirdSegment;
2693 size_type remaining = numElements > secondSegment
2697 std::memmove((
void *)destination->
valuePtr(),
2699 remaining *
sizeof(VALUE_TYPE));
2701 *destination += remaining;
2702 *source += remaining;
2703 numElements -= remaining;
2705 std::memmove((
void *)destination->
valuePtr(),
2707 numElements *
sizeof(VALUE_TYPE));
2709 *destination += numElements;
2710 *source += numElements;
2713template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2714template <
class ALLOCATOR>
2720 const VALUE_TYPE& value,
2721 ALLOCATOR allocator)
2728 fromEnd += numElements;
2740 numElements -= firstRemaining;
2741 fromEnd += firstRemaining;
2744 for ( ; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2758 fromEnd += numElements;
2762template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2763template <
class ALLOCATOR>
2769 ALLOCATOR allocator)
2775 fromEnd += numElements;
2786 numElements -= firstRemaining;
2787 fromEnd += firstRemaining;
2790 for ( ; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2802 fromEnd += numElements;
2806template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2807template <
class ALLOCATOR>
2813 const VALUE_TYPE& value,
2814 ALLOCATOR allocator)
2817 fromBegin -= numElements;
2823 *toBegin = fromBegin;
2829 fromBegin -= firstRemaining;
2830 numElements -= firstRemaining;
2837 *toBegin = fromBegin;
2839 for ( ; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2845 *toBegin = fromBegin;
2848 fromBegin -= numElements;
2854 *toBegin = fromBegin;
2862template <
class VALUE_TYPE>
2863template <
class ALLOCATOR>
2871 ALLOCATOR allocator)
2873 size_type frontSize = first - fromBegin;
2877 if (frontSize < backSize) {
2879 for (; 0 < frontSize; --frontSize) {
2889 for (; 0 < backSize; --backSize, ++first, ++last) {
2892 *toBegin = fromBegin;
2895 destruct(first, last, allocator);
2899template <
class VALUE_TYPE>
2900template <
class ALLOCATOR>
2903 ALLOCATOR allocator)
2905 for (; !(begin == end); ++begin) {
2911template <
class VALUE_TYPE>
2912template <
class ALLOCATOR>
2919 const VALUE_TYPE& value,
2920 ALLOCATOR allocator)
2924 ALLOCATOR> ElementGuard;
2926 size_type frontSize = position - fromBegin;
2928 Iterator dest = begin - numElements;
2944 ElementGuard guard(dest, dest, allocator);
2945 if (frontSize >= numElements) {
2946 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
2952 for (frontSize -= numElements; 0 < frontSize;
2953 --frontSize, ++dest, ++begin) {
2956 for (numDest = numElements; 0 < numDest; --numDest, ++dest) {
2960 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
2966 for (numDest = numElements; frontSize < numDest; --numDest, ++dest) {
2972 for (; 0 < numDest; --numDest, ++dest) {
2977 *toBegin = fromBegin - numElements;
2980template <
class VALUE_TYPE>
2981template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
2990 ALLOCATOR allocator)
2994 ALLOCATOR> ElementGuard;
2996 size_type frontSize = position - fromBegin;
2998 Iterator dest = begin - numElements;
3001 ElementGuard guard(dest, dest, allocator);
3002 if (frontSize >= numElements) {
3003 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
3009 for (frontSize -= numElements; 0 < frontSize;
3010 --frontSize, ++dest, ++begin) {
3013 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++first) {
3017 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
3023 for (numDest = numElements; frontSize < numDest;
3024 --numDest, ++dest, ++first) {
3030 for (; 0 < numDest; --numDest, ++dest, ++first) {
3035 *toBegin = fromBegin - numElements;
3038template <
class VALUE_TYPE>
3039template <
class ALLOCATOR>
3046 const VALUE_TYPE& value,
3047 ALLOCATOR allocator)
3051 ALLOCATOR> ElementGuard;
3053 size_type backSize = fromEnd - position;
3071 ElementGuard guard(dest, dest, allocator);
3072 if (backSize >= numElements) {
3073 for (numDest = numElements; 0 < numDest; --numDest) {
3079 guard.moveBegin(-1);
3081 for (backSize -= numElements; 0 < backSize; --backSize) {
3086 for (numDest = numElements; 0 < numDest; --numDest, ++position) {
3087 *position = space.
object();
3090 for (numDest = backSize; 0 < numDest; --numDest) {
3096 guard.moveBegin(-1);
3098 for (numDest = numElements; backSize < numDest; --numDest) {
3103 guard.moveBegin(-1);
3105 for (; 0 < numDest; --numDest, ++position) {
3106 *position = space.
object();
3110 *toEnd = fromEnd + numElements;
3113template <
class VALUE_TYPE>
3114template <
class FWD_ITER,
class SENTINEL,
class ALLOCATOR>
3122 ALLOCATOR allocator)
3126 ALLOCATOR> ElementGuard;
3128 size_type backSize = fromEnd - position;
3133 ElementGuard guard(dest, dest, allocator);
3134 if (backSize >= numElements) {
3135 for (numDest = numElements; 0 < numDest; --numDest) {
3141 guard.moveBegin(-1);
3143 for (numDest = backSize; numElements < numDest; --numDest) {
3148 for (; 0 < numDest; ++first, ++position, --numDest) {
3152 for (numDest = backSize; 0 < numDest; --numDest) {
3158 guard.moveBegin(-1);
3160 for (numDest = backSize; 0 < numDest; --numDest, ++position, ++first) {
3163 ElementGuard guard2(position, position, allocator);
3164 for (numDest = numElements; backSize < numDest; ++first, ++position,
3167 position.valuePtr(),
3174 *toEnd = fromEnd + numElements;
3177template <
class VALUE_TYPE>
3178template <
class ALLOCATOR>
3185 const VALUE_TYPE& value,
3186 ALLOCATOR allocator)
3193 IS_FUNDAMENTAL_OR_POINTER = IS_FUNDAMENTAL ||
3194 (IS_POINTER && !IS_FUNCTION_POINTER),
3198 VALUE = IS_FUNDAMENTAL_OR_POINTER || IS_BITWISECOPYABLE
3203 uninitializedFillNFront(toBegin,
3211template <
class VALUE_TYPE>
3212template <
class ALLOCATOR>
3217 const VALUE_TYPE& value,
3218 ALLOCATOR allocator,
3223 ALLOCATOR> ElementGuard;
3225 ElementGuard guard(fromBegin, fromBegin, allocator);
3226 for (; 0 < numElements; --numElements) {
3231 guard.moveBegin(-1);
3234 *toBegin = fromBegin;
3237template <
class VALUE_TYPE>
3238template <
class ALLOCATOR>
3243 const VALUE_TYPE& value,
3244 ALLOCATOR allocator,
3247 *toBegin = fromBegin;
3248 for ( ; 0 < numElements; --numElements) {
3254 *toBegin = fromBegin;
3258template <
class VALUE_TYPE>
3259template <
class ALLOCATOR>
3266 const VALUE_TYPE& value,
3267 ALLOCATOR allocator)
3274 IS_FUNDAMENTAL_OR_POINTER = IS_FUNDAMENTAL ||
3275 (IS_POINTER && !IS_FUNCTION_POINTER),
3279 VALUE = IS_FUNDAMENTAL_OR_POINTER || IS_BITWISECOPYABLE
3284 uninitializedFillNBack(toEnd,
3292template <
class VALUE_TYPE>
3293template <
class ALLOCATOR>
3298 const VALUE_TYPE& value,
3299 ALLOCATOR allocator,
3304 ALLOCATOR> ElementGuard;
3306 ElementGuard guard(fromEnd, fromEnd, allocator);
3307 for (; 0 < numElements; --numElements) {
3318template <
class VALUE_TYPE>
3319template <
class ALLOCATOR>
3324 const VALUE_TYPE& value,
3325 ALLOCATOR allocator,
3329 for ( ; 0 < numElements; --numElements) {
3339template <
class VALUE_TYPE>
3340template <
class ALLOCATOR>
3346 ALLOCATOR allocator)
3353 IS_FUNDAMENTAL_OR_POINTER = IS_FUNDAMENTAL ||
3354 (IS_POINTER && !IS_FUNCTION_POINTER),
3358 VALUE = IS_FUNDAMENTAL_OR_POINTER || IS_BITWISECOPYABLE
3363 valueInititalizeN(toEnd,
3370template <
class VALUE_TYPE>
3371template <
class ALLOCATOR>
3376 ALLOCATOR allocator,
3381 ALLOCATOR> ElementGuard;
3383 ElementGuard guard(fromEnd, fromEnd, allocator);
3384 for (; 0 < numElements; --numElements) {
3394template <
class VALUE_TYPE>
3395template <
class ALLOCATOR>
3400 ALLOCATOR allocator,
3404 for ( ; 0 < numElements; --numElements) {
3418template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3423 ALLOCATOR allocator)
3426, d_allocator(allocator)
3430template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3441template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3444<VALUE_TYPE, BLOCK_LENGTH, ALLOCATOR>::Iterator&
3452template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3455<VALUE_TYPE, BLOCK_LENGTH, ALLOCATOR>::Iterator&
3463template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3476template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3481 ALLOCATOR allocator)
3484, d_allocator(allocator)
3488template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3493 if (d_begin_p != d_end_p) {
3501template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3507 d_begin_p = d_end_p = 0;
3515template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3522: d_destination_p(dest)
3529template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3537 d_destination_p += d_size;
3538 d_source_p += d_size;
3543 d_destination_p -= d_size;
3544 d_source_p -= d_size;
3551template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3563template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3568: d_endpoint_p(endpoint)
3569, d_position(position)
3573template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3578 if (0 != d_endpoint_p) {
3579 *d_endpoint_p = d_position;
3584template <
class VALUE_TYPE,
int BLOCK_LENGTH>
Definition bslalg_dequeiterator.h:351
VALUE_TYPE * valuePtr() const
Definition bslalg_dequeiterator.h:819
Definition bslalg_dequeiterator.h:158
void previousBlock()
Definition bslalg_dequeiterator.h:511
std::size_t offsetInBlock() const
Definition bslalg_dequeiterator.h:618
std::size_t remainingInBlock() const
Definition bslalg_dequeiterator.h:626
VALUE_TYPE * valuePtr() const
Definition bslalg_dequeiterator.h:634
void nextBlock()
Set this iterator to point to the first element of the next block.
Definition bslalg_dequeiterator.h:503
Definition bslalg_dequeprimitives.h:947
Iterator & moveEnd(std::ptrdiff_t offset=1)
Definition bslalg_dequeprimitives.h:3457
Iterator & moveBegin(std::ptrdiff_t offset=-1)
Definition bslalg_dequeprimitives.h:3446
void release()
Definition bslalg_dequeprimitives.h:3466
~DequePrimitives_DequeElementGuard()
Definition bslalg_dequeprimitives.h:3433
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:951
Definition bslalg_dequeprimitives.h:1128
void release()
Definition bslalg_dequeprimitives.h:3586
~DequePrimitives_DequeEndpointProctor()
Definition bslalg_dequeprimitives.h:3576
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:1132
Definition bslalg_dequeprimitives.h:1074
void release()
Set the size of the range guarded by this object to be zero.
Definition bslalg_dequeprimitives.h:3553
~DequePrimitives_DequeMoveGuard()
Definition bslalg_dequeprimitives.h:3532
bslalg::DequePrimitives< VALUE_TYPE, BLOCK_LENGTH > DequePrimitives
Definition bslalg_dequeprimitives.h:1079
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:1078
Definition bslalg_dequeprimitives.h:1015
~DequePrimitives_ExternalDequeElementGuard()
Definition bslalg_dequeprimitives.h:3491
void release()
Definition bslalg_dequeprimitives.h:3505
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:1019
Definition bslma_destructorproctor.h:259
Definition bslmf_movableref.h:752
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:296
Definition bdlc_flathashmap.h:2218
@ BSLALG_DEQUEPRIMITIVES_BITWISE_COPYABLE_TRAITS
Definition bslalg_dequeprimitives.h:224
@ BSLALG_DEQUEPRIMITIVES_NON_NIL_TRAITS
Definition bslalg_dequeprimitives.h:225
@ BSLALG_DEQUEPRIMITIVES_BITWISE_MOVEABLE_TRAITS
Definition bslalg_dequeprimitives.h:223
@ BSLALG_DEQUEPRIMITIVES_NIL_TRAITS
Definition bslalg_dequeprimitives.h:222
static void construct(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr, Args &&... arguments)
Definition bslma_allocatortraits.h:1527
static void destroy(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr)
Definition bslma_allocatortraits.h:1549
Definition bslmf_integralconstant.h:261
static void defaultConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2129
static void uninitializedFillN(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, size_type numElements, const typename bsl::allocator_traits< ALLOCATOR >::value_type &value, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:1970
Definition bslalg_dequeimputil.h:126
static Iterator erase(Iterator *toBegin, Iterator *toEnd, Iterator fromBegin, Iterator first, Iterator last, Iterator fromEnd, ALLOCATOR allocator)
DequeImpUtil< VALUE_TYPE, 1 > ImpUtil
Definition bslalg_dequeprimitives.h:815
std::size_t size_type
Definition bslalg_dequeprimitives.h:814
DequeIterator< VALUE_TYPE, 1 > Iterator
Definition bslalg_dequeprimitives.h:816
Definition bslalg_dequeprimitives.h:241
static void moveBack(Iterator *destination, Iterator *source, size_type numElements)
Definition bslalg_dequeprimitives.h:2463
static void insertAndMoveToBack(Iterator *toEnd, Iterator fromEnd, Iterator position, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1339
static void insertAndMoveToFront(Iterator *toBegin, Iterator fromBegin, Iterator position, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1754
static void uninitializedFillNFront(Iterator *toBegin, Iterator fromBegin, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2810
static void uninitializedFillNBack(Iterator *toEnd, Iterator fromEnd, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2717
static void moveInsertAndMoveToFront(Iterator *toBegin, Iterator fromBegin, Iterator position, bslmf::MovableRef< VALUE_TYPE > value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2005
static void emplaceAndMoveToBack(Iterator *toEnd, Iterator fromEnd, Iterator position, ALLOCATOR allocator, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2146
std::size_t size_type
Definition bslalg_dequeprimitives.h:244
static void emplaceAndMoveToFront(Iterator *toBegin, Iterator fromBegin, Iterator position, ALLOCATOR allocator, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2307
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:245
static void valueInititalizeN(Iterator *toEnd, Iterator fromEnd, size_type numElements, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2766
static void moveInsertAndMoveToBack(Iterator *toEnd, Iterator fromEnd, Iterator position, bslmf::MovableRef< VALUE_TYPE > value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1609
static Iterator erase(Iterator *toBegin, Iterator *toEnd, Iterator fromBegin, Iterator first, Iterator last, Iterator fromEnd, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1229
static void destruct(Iterator begin, Iterator end, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1181
static void moveFront(Iterator *destination, Iterator *source, size_type numElements)
Definition bslalg_dequeprimitives.h:2589
static void emplaceAndMoveToFrontDispatch(Iterator *toBegin, Iterator fromBegin, Iterator position, ALLOCATOR allocator, bsl::integral_constant< int, BSLALG_DEQUEPRIMITIVES_BITWISE_COPYABLE_TRAITS >, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2336
static void emplaceAndMoveToBackDispatch(Iterator *toEnd, Iterator fromEnd, Iterator position, ALLOCATOR allocator, bsl::integral_constant< int, BSLALG_DEQUEPRIMITIVES_BITWISE_COPYABLE_TRAITS >, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2175
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1244
static Allocator * allocator(Allocator *basicAllocator=0)
Definition bslma_default.h:913
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_functionpointertraits.h:163
Definition bslmf_isfundamental.h:303
Definition bslmf_ispointer.h:198
Definition bslmf_movableref.h:795
Definition bsls_objectbuffer.h:277
TYPE & object()
Definition bsls_objectbuffer.h:352