8#ifndef INCLUDED_BSLALG_DEQUEPRIMITIVES
9#define INCLUDED_BSLALG_DEQUEPRIMITIVES
160#include <bslscm_version.h>
187#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
191# define COMPILING_BSLALG_DEQUEPRIMITIVES_H
193# undef COMPILING_BSLALG_DEQUEPRIMITIVES_H
211 BITWISE_MOVEABLE_TRAITS = 1,
212 BITWISE_COPYABLE_TRAITS = 2,
220template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
221class DequePrimitives_DequeElementGuard;
223template <
class VALUE_TYPE,
int BLOCK_LENGTH>
224class DequePrimitives_DequeMoveGuard;
226template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
227class DequePrimitives_ExternalDequeElementGuard;
229template <
class VALUE_TYPE,
int BLOCK_LENGTH>
230class DequePrimitives_DequeEndpointProctor;
242template <
class VALUE_TYPE,
int BLOCK_LENGTH>
264 template <
class ALLOCATOR>
273 template <
class ALLOCATOR>
279 template <
class ALLOCATOR>
295 template <
class ALLOCATOR>
302 ALLOCATOR allocator);
314 template <
class ALLOCATOR>
324 template <
class ALLOCATOR>
344 template <
class ALLOCATOR>
349 const VALUE_TYPE& value,
350 ALLOCATOR allocator);
362 template <
class ALLOCATOR>
368 const VALUE_TYPE& value,
371 template <
class ALLOCATOR>
377 const VALUE_TYPE& value,
380 template <
class ALLOCATOR>
386 const VALUE_TYPE& value,
399 template <
class FWD_ITER,
class ALLOCATOR>
406 ALLOCATOR allocator);
416 template <
class ALLOCATOR>
422 ALLOCATOR allocator);
433 template <
class ALLOCATOR>
441 template <
class ALLOCATOR>
449 template <
class ALLOCATOR>
467 template <
class ALLOCATOR>
472 const VALUE_TYPE& value,
473 ALLOCATOR allocator);
485 template <
class ALLOCATOR>
491 const VALUE_TYPE& value,
494 template <
class ALLOCATOR>
500 const VALUE_TYPE& value,
503 template <
class ALLOCATOR>
509 const VALUE_TYPE& value,
522 template <
class FWD_ITER,
class ALLOCATOR>
529 ALLOCATOR allocator);
540 template <
class ALLOCATOR>
546 ALLOCATOR allocator);
558 template <
class ALLOCATOR>
566 template <
class ALLOCATOR>
574 template <
class ALLOCATOR>
583#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
593 template <
class ALLOCATOR,
class... Args>
598 Args&&... arguments);
611 template <
class ALLOCATOR,
class... Args>
618 Args&&... arguments);
619 template <
class ALLOCATOR,
class... Args>
626 Args&&... arguments);
627 template <
class ALLOCATOR,
class... Args>
634 Args&&... arguments);
646 template <
class ALLOCATOR,
class... Args>
651 Args&&... arguments);
664 template <
class ALLOCATOR,
class... Args>
671 Args&&... arguments);
672 template <
class ALLOCATOR,
class... Args>
679 Args&&... arguments);
680 template <
class ALLOCATOR,
class... Args>
687 Args&&... arguments);
716 template <
class ALLOCATOR>
720 const VALUE_TYPE& value,
721 ALLOCATOR allocator);
731 template <
class ALLOCATOR>
735 const VALUE_TYPE& value,
736 ALLOCATOR allocator);
746 template <
class ALLOCATOR>
750 ALLOCATOR allocator);
757template <
class VALUE_TYPE>
766 template <
class ALLOCATOR>
769 template <
class ALLOCATOR>
776 ALLOCATOR allocator);
778 template <
class ALLOCATOR>
783 const VALUE_TYPE& value,
784 ALLOCATOR allocator);
786 template <
class FWD_ITER,
class ALLOCATOR>
793 ALLOCATOR allocator);
795 template <
class ALLOCATOR>
800 const VALUE_TYPE& value,
801 ALLOCATOR allocator);
803 template <
class FWD_ITER,
class ALLOCATOR>
810 ALLOCATOR allocator);
812 template <
class ALLOCATOR>
816 const VALUE_TYPE& value,
817 ALLOCATOR allocator);
818 template <
class ALLOCATOR>
823 const VALUE_TYPE& value,
826 template <
class ALLOCATOR>
831 const VALUE_TYPE& value,
835 template <
class ALLOCATOR>
839 const VALUE_TYPE& value,
840 ALLOCATOR allocator);
841 template <
class ALLOCATOR>
846 const VALUE_TYPE& value,
849 template <
class ALLOCATOR>
854 const VALUE_TYPE& value,
858 template <
class ALLOCATOR>
862 ALLOCATOR allocator);
864 template <
class ALLOCATOR>
872 template <
class ALLOCATOR>
892template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
903 ALLOCATOR d_allocator;
922 ALLOCATOR allocator);
957template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
971 ALLOCATOR d_allocator;
990 ALLOCATOR allocator);
1014template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1068template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1119template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1120template <
class ALLOCATOR>
1124 ALLOCATOR allocator)
1129 VALUE = IS_BITWISECOPYABLE
1130 ? BITWISE_COPYABLE_TRAITS
1134 return destruct(begin,
1140template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1141template <
class ALLOCATOR>
1151template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1152template <
class ALLOCATOR>
1156 ALLOCATOR allocator,
1159 for (; !(begin == end); ++begin) {
1165template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1166template <
class ALLOCATOR>
1176 ALLOCATOR allocator)
1181 VALUE = IS_BITWISECOPYABLE
1182 ? BITWISE_COPYABLE_TRAITS
1186 return erase(toBegin,
1196template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1197template <
class ALLOCATOR>
1207 ALLOCATOR allocator,
1210 if (first == last) {
1211 *toBegin = fromBegin;
1216 size_type frontSize = first - fromBegin;
1220 if (frontSize < backSize) {
1222 for (; 0 < frontSize; --frontSize) {
1225 *last = MoveUtil::move(*first);
1232 for (; 0 < backSize; --backSize, ++first, ++last) {
1233 *first = MoveUtil::move(*last);
1235 *toBegin = fromBegin;
1238 destruct(first, last, allocator);
1242template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1243template <
class ALLOCATOR>
1256 size_type frontSize = first - fromBegin;
1260 if (frontSize < backSize) {
1262 moveBack(&last, &first, frontSize);
1268 moveFront(&first, &last, backSize);
1269 *toBegin = fromBegin;
1276template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1277template <
class ALLOCATOR>
1285 const VALUE_TYPE& value,
1286 ALLOCATOR allocator)
1292 VALUE = IS_BITWISECOPYABLE
1293 ? BITWISE_COPYABLE_TRAITS : IS_BITWISEMOVEABLE
1294 ? BITWISE_MOVEABLE_TRAITS : NIL_TRAITS
1297 insertAndMoveToBack(toEnd,
1306template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1307template <
class ALLOCATOR>
1314 const VALUE_TYPE& value,
1315 ALLOCATOR allocator,
1318 size_type backSize = fromEnd - position;
1338 moveBack(&dest, &end, backSize);
1339 uninitializedFillNFront(&dest, dest, numElements, space.
object(),
1342 *toEnd = fromEnd + numElements;
1345template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1346template <
class ALLOCATOR>
1353 const VALUE_TYPE& value,
1354 ALLOCATOR allocator,
1359 ALLOCATOR> ExtGuard;
1362 size_type backSize = fromEnd - position;
1383 MoveGuard guard(end, dest, backSize,
false);
1385 moveBack(&dest, &end, backSize);
1391 ExtGuard eguard(&dest, &dest2, allocator);
1393 uninitializedFillNFront(&dest, dest, numElements, space.
object(),
1397 *toEnd = fromEnd + numElements;
1400template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1401template <
class ALLOCATOR>
1408 const VALUE_TYPE& value,
1409 ALLOCATOR allocator,
1414 ALLOCATOR> ElementGuard;
1416 size_type backSize = fromEnd - position;
1436 ElementGuard guard(dest, dest, allocator);
1437 if (backSize >= numElements) {
1438 for (numDest = numElements; 0 < numDest; --numDest) {
1444 guard.moveBegin(-1);
1446 for (backSize -= numElements; 0 < backSize; --backSize) {
1451 for (numDest = numElements; 0 < numDest; --numDest, ++position) {
1452 *position = space.
object();
1455 for (numDest = backSize; 0 < numDest; --numDest) {
1461 guard.moveBegin(-1);
1463 for (numDest = numElements; backSize < numDest; --numDest) {
1469 guard.moveBegin(-1);
1471 for (; 0 < numDest; --numDest, ++position) {
1472 *position = space.
object();
1477 *toEnd = fromEnd + numElements;
1480template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1481template <
class FWD_ITER,
class ALLOCATOR>
1490 ALLOCATOR allocator)
1494 ALLOCATOR> ElementGuard;
1496 size_type backSize = fromEnd - position;
1501 ElementGuard guard(dest, dest, allocator);
1502 if (backSize >= numElements) {
1503 for (numDest = numElements; 0 < numDest; --numDest) {
1509 guard.moveBegin(-1);
1511 for (numDest = backSize; numElements < numDest; --numDest) {
1516 for (; 0 < numDest; ++first, ++position, --numDest) {
1520 for (numDest = backSize; 0 < numDest; --numDest) {
1526 guard.moveBegin(-1);
1528 for (numDest = backSize; 0 < numDest; --numDest, ++position, ++first) {
1532 ElementGuard guard2(position, position, allocator);
1533 for (numDest = numElements; backSize < numDest; ++first, ++position,
1536 position.valuePtr(),
1543 *toEnd = fromEnd + numElements;
1546template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1547template <
class ALLOCATOR>
1555 ALLOCATOR allocator)
1561 VALUE = IS_BITWISECOPYABLE
1562 ? BITWISE_COPYABLE_TRAITS : IS_BITWISEMOVEABLE
1563 ? BITWISE_MOVEABLE_TRAITS : NIL_TRAITS
1566 VALUE_TYPE& lvalue = value;
1568 moveInsertAndMoveToBack(toEnd,
1571 MoveUtil::move(lvalue),
1576template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1577template <
class ALLOCATOR>
1584 ALLOCATOR allocator,
1587 const size_type backSize = fromEnd - position;
1594 moveBack(&dest, &end, backSize);
1597 VALUE_TYPE& lvalue = value;
1600 MoveUtil::move(lvalue));
1602 *toEnd = fromEnd + 1;
1605template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1606template <
class ALLOCATOR>
1613 ALLOCATOR allocator,
1616 const size_type backSize = fromEnd - position;
1623 MoveGuard guard(end, dest, backSize,
false);
1625 moveBack(&dest, &end, backSize);
1628 VALUE_TYPE& lvalue = value;
1631 MoveUtil::move(lvalue));
1635 *toEnd = fromEnd + 1;
1638template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1639template <
class ALLOCATOR>
1646 ALLOCATOR allocator,
1651 ALLOCATOR> ElementGuard;
1653 size_type backSize = fromEnd - position;
1659 ElementGuard guard(dest, dest, allocator);
1668 MoveUtil::move_if_noexcept(*end));
1669 guard.moveBegin(-1);
1673 for (backSize -= 1; 0 < backSize; --backSize) {
1676 *dest = MoveUtil::move_if_noexcept(*end);
1681 VALUE_TYPE& lvalue = value;
1682 *position = MoveUtil::move(lvalue);
1686 *toEnd = fromEnd + 1;
1689template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1690template <
class ALLOCATOR>
1698 const VALUE_TYPE& value,
1699 ALLOCATOR allocator)
1705 VALUE = IS_BITWISECOPYABLE
1706 ? BITWISE_COPYABLE_TRAITS : IS_BITWISEMOVEABLE
1707 ? BITWISE_MOVEABLE_TRAITS : NIL_TRAITS
1710 insertAndMoveToFront(toBegin,
1719template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1720template <
class ALLOCATOR>
1727 const VALUE_TYPE& value,
1728 ALLOCATOR allocator,
1731 size_type frontSize = position - fromBegin;
1733 Iterator dest = begin - numElements;
1751 moveFront(&dest, &begin, frontSize);
1752 uninitializedFillNBack(&dest, dest, numElements, space.
object(),
1755 *toBegin = fromBegin - numElements;
1758template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1759template <
class ALLOCATOR>
1766 const VALUE_TYPE& value,
1767 ALLOCATOR allocator,
1772 ALLOCATOR> ExtGuard;
1773 size_type frontSize = position - fromBegin;
1775 Iterator dest = begin - numElements;
1793 MoveGuard guard(begin, dest, frontSize,
true);
1795 moveFront(&dest, &begin, frontSize);
1801 ExtGuard eguard(&dest2, &dest, allocator);
1803 uninitializedFillNBack(&dest, dest, numElements, space.
object(),
1808 *toBegin = fromBegin - numElements;
1811template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1812template <
class ALLOCATOR>
1819 const VALUE_TYPE& value,
1820 ALLOCATOR allocator,
1825 ALLOCATOR> ElementGuard;
1827 size_type frontSize = position - fromBegin;
1829 Iterator dest = begin - numElements;
1846 ElementGuard guard(dest, dest, allocator);
1847 if (frontSize >= numElements) {
1848 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
1854 for (frontSize -= numElements; 0 < frontSize;
1855 --frontSize, ++dest, ++begin) {
1858 for (numDest = numElements; 0 < numDest; --numDest, ++dest) {
1862 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
1868 for (numDest = numElements; frontSize < numDest; --numDest, ++dest) {
1874 for (; 0 < numDest; --numDest, ++dest) {
1879 *toBegin = fromBegin - numElements;
1882template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1883template <
class FWD_ITER,
class ALLOCATOR>
1892 ALLOCATOR allocator)
1896 ALLOCATOR> ElementGuard;
1898 size_type frontSize = position - fromBegin;
1900 Iterator dest = begin - numElements;
1903 ElementGuard guard(dest, dest, allocator);
1904 if (frontSize >= numElements) {
1905 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
1911 for (frontSize -= numElements; 0 < frontSize;
1912 --frontSize, ++dest, ++begin) {
1915 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++first) {
1919 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
1925 for (numDest = numElements; frontSize < numDest;
1926 --numDest, ++dest, ++first) {
1932 for (; 0 < numDest; --numDest, ++dest, ++first) {
1937 *toBegin = fromBegin - numElements;
1940template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1941template <
class ALLOCATOR>
1949 ALLOCATOR allocator)
1955 VALUE = IS_BITWISECOPYABLE
1956 ? BITWISE_COPYABLE_TRAITS : IS_BITWISEMOVEABLE
1957 ? BITWISE_MOVEABLE_TRAITS : NIL_TRAITS
1960 VALUE_TYPE& lvalue = value;
1962 moveInsertAndMoveToFront(toBegin,
1965 MoveUtil::move(lvalue),
1970template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1971template <
class ALLOCATOR>
1978 ALLOCATOR allocator,
1981 const size_type frontSize = position - fromBegin;
1988 moveFront(&dest, &begin, frontSize);
1990 VALUE_TYPE& lvalue = value;
1993 MoveUtil::move(lvalue));
1995 *toBegin = fromBegin - 1;
1998template <
class VALUE_TYPE,
int BLOCK_LENGTH>
1999template <
class ALLOCATOR>
2006 ALLOCATOR allocator,
2009 const size_type frontSize = position - fromBegin;
2016 MoveGuard guard(begin, dest, frontSize,
true);
2018 moveFront(&dest, &begin, frontSize);
2020 VALUE_TYPE& lvalue = value;
2023 MoveUtil::move(lvalue));
2027 *toBegin = fromBegin - 1;
2030template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2031template <
class ALLOCATOR>
2038 ALLOCATOR allocator,
2043 ALLOCATOR> ElementGuard;
2045 size_type frontSize = position - fromBegin;
2051 ElementGuard guard(dest, dest, allocator);
2058 MoveUtil::move_if_noexcept(*begin));
2065 for (frontSize -= 1; 0 < frontSize; --frontSize, ++dest, ++begin) {
2066 *dest = MoveUtil::move_if_noexcept(*begin);
2071 VALUE_TYPE& lvalue = value;
2072 *dest = MoveUtil::move(lvalue);
2076 *toBegin = fromBegin - 1;
2079#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2080template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2081template <
class ALLOCATOR,
class... Args>
2088 ALLOCATOR allocator,
2089 Args&&... arguments)
2095 VALUE = IS_BITWISECOPYABLE
2096 ? BITWISE_COPYABLE_TRAITS : IS_BITWISEMOVEABLE
2097 ? BITWISE_MOVEABLE_TRAITS : NIL_TRAITS
2100 emplaceAndMoveToBackDispatch(
2109template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2110template <
class ALLOCATOR,
class... Args>
2116 ALLOCATOR allocator,
2118 Args&&... arguments)
2120 const size_type backSize = fromEnd - position;
2127 moveBack(&dest, &end, backSize);
2135 *toEnd = fromEnd + 1;
2138template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2139template <
class ALLOCATOR,
class... Args>
2145 ALLOCATOR allocator,
2147 Args&&... arguments)
2149 const size_type backSize = fromEnd - position;
2156 MoveGuard guard(end, dest, backSize,
false);
2158 moveBack(&dest, &end, backSize);
2168 *toEnd = fromEnd + 1;
2171template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2172template <
class ALLOCATOR,
class... Args>
2178 ALLOCATOR allocator,
2180 Args&&... arguments)
2184 ALLOCATOR> ElementGuard;
2187 BLOCK_LENGTH> EndpointProctor;
2189 size_type backSize = fromEnd - position;
2195 ElementGuard guard(dest, dest, allocator);
2204 MoveUtil::move_if_noexcept(*end));
2205 guard.moveBegin(-1);
2210 for (backSize -= 1; 0 < backSize; --backSize) {
2213 *dest = MoveUtil::move_if_noexcept(*end);
2216 guard.moveBegin(-n);
2227 EndpointProctor endpointProctor(toEnd, position);
2234 endpointProctor.release();
2237 *toEnd = fromEnd + 1;
2240template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2241template <
class ALLOCATOR,
class... Args>
2248 ALLOCATOR allocator,
2249 Args&&... arguments)
2255 VALUE = IS_BITWISECOPYABLE
2256 ? BITWISE_COPYABLE_TRAITS : IS_BITWISEMOVEABLE
2257 ? BITWISE_MOVEABLE_TRAITS : NIL_TRAITS
2260 emplaceAndMoveToFrontDispatch(
2269template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2270template <
class ALLOCATOR,
class... Args>
2276 ALLOCATOR allocator,
2278 Args&&... arguments)
2280 const size_type frontSize = position - fromBegin;
2287 moveFront(&dest, &begin, frontSize);
2294 *toBegin = fromBegin - 1;
2297template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2298template <
class ALLOCATOR,
class... Args>
2304 ALLOCATOR allocator,
2306 Args&&... arguments)
2308 const size_type frontSize = position - fromBegin;
2315 MoveGuard guard(begin, dest, frontSize,
true);
2317 moveFront(&dest, &begin, frontSize);
2326 *toBegin = fromBegin - 1;
2329template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2330template <
class ALLOCATOR,
class... Args>
2336 ALLOCATOR allocator,
2338 Args&&... arguments)
2342 ALLOCATOR> ElementGuard;
2345 BLOCK_LENGTH> EndpointProctor;
2347 size_type frontSize = position - fromBegin;
2353 ElementGuard guard(dest, dest, allocator);
2360 MoveUtil::move_if_noexcept(*begin));
2368 for (frontSize -= 1; 0 < frontSize; --frontSize, ++dest, ++begin) {
2369 *dest = MoveUtil::move_if_noexcept(*begin);
2383 EndpointProctor endpointProctor(toBegin, position);
2390 endpointProctor.release();
2393 *toBegin = fromBegin - 1;
2397template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2407 *destination -= numElements;
2408 *source -= numElements;
2409 std::memmove((
void *)destination->
valuePtr(),
2411 numElements *
sizeof(VALUE_TYPE));
2473 secondSegment = destination->
offsetInBlock() - firstSegment;
2476 size_type thirdSegment = BLOCK_LENGTH - secondSegment;
2478 *destination -= firstSegment;
2479 *source -= firstSegment;
2480 numElements -= firstSegment;
2482 std::memmove((
void *)destination->
valuePtr(),
2484 firstSegment *
sizeof(VALUE_TYPE));
2486 for (; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2488 *destination -= secondSegment;
2489 *source -= secondSegment;
2491 std::memmove((
void *)destination->
valuePtr(),
2493 secondSegment *
sizeof(VALUE_TYPE));
2495 *destination -= thirdSegment;
2496 *source -= thirdSegment;
2498 std::memmove((
void *)destination->
valuePtr(),
2500 thirdSegment *
sizeof(VALUE_TYPE));
2503 size_type remaining = numElements > secondSegment
2507 *destination -= remaining;
2508 *source -= remaining;
2509 numElements -= remaining;
2511 std::memmove((
void *)destination->
valuePtr(),
2513 remaining *
sizeof(VALUE_TYPE));
2515 *destination -= numElements;
2516 *source -= numElements;
2518 std::memmove((
void *)destination->
valuePtr(),
2520 numElements *
sizeof(VALUE_TYPE));
2523template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2533 std::memmove((
void *)destination->
valuePtr(),
2535 numElements *
sizeof(VALUE_TYPE));
2536 *destination += numElements;
2537 *source += numElements;
2602 size_type thirdSegment = BLOCK_LENGTH - secondSegment;
2604 std::memmove((
void *)destination->
valuePtr(),
2606 firstSegment *
sizeof(VALUE_TYPE));
2608 *destination += firstSegment;
2609 *source += firstSegment;
2610 numElements -= firstSegment;
2612 for (; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2614 std::memmove((
void *)destination->
valuePtr(),
2616 secondSegment *
sizeof(VALUE_TYPE));
2618 *destination += secondSegment;
2619 *source += secondSegment;
2621 std::memmove((
void *)destination->
valuePtr(),
2623 thirdSegment *
sizeof(VALUE_TYPE));
2625 *destination += thirdSegment;
2626 *source += thirdSegment;
2629 size_type remaining = numElements > secondSegment
2633 std::memmove((
void *)destination->
valuePtr(),
2635 remaining *
sizeof(VALUE_TYPE));
2637 *destination += remaining;
2638 *source += remaining;
2639 numElements -= remaining;
2641 std::memmove((
void *)destination->
valuePtr(),
2643 numElements *
sizeof(VALUE_TYPE));
2645 *destination += numElements;
2646 *source += numElements;
2649template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2650template <
class ALLOCATOR>
2656 const VALUE_TYPE& value,
2657 ALLOCATOR allocator)
2664 fromEnd += numElements;
2676 numElements -= firstRemaining;
2677 fromEnd += firstRemaining;
2680 for ( ; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2694 fromEnd += numElements;
2698template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2699template <
class ALLOCATOR>
2705 ALLOCATOR allocator)
2711 fromEnd += numElements;
2722 numElements -= firstRemaining;
2723 fromEnd += firstRemaining;
2726 for ( ; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2738 fromEnd += numElements;
2742template <
class VALUE_TYPE,
int BLOCK_LENGTH>
2743template <
class ALLOCATOR>
2749 const VALUE_TYPE& value,
2750 ALLOCATOR allocator)
2753 fromBegin -= numElements;
2759 *toBegin = fromBegin;
2765 fromBegin -= firstRemaining;
2766 numElements -= firstRemaining;
2773 *toBegin = fromBegin;
2775 for ( ; numElements >= BLOCK_LENGTH; numElements -= BLOCK_LENGTH) {
2781 *toBegin = fromBegin;
2784 fromBegin -= numElements;
2790 *toBegin = fromBegin;
2798template <
class VALUE_TYPE>
2799template <
class ALLOCATOR>
2807 ALLOCATOR allocator)
2809 size_type frontSize = first - fromBegin;
2813 if (frontSize < backSize) {
2815 for (; 0 < frontSize; --frontSize) {
2825 for (; 0 < backSize; --backSize, ++first, ++last) {
2828 *toBegin = fromBegin;
2831 destruct(first, last, allocator);
2835template <
class VALUE_TYPE>
2836template <
class ALLOCATOR>
2839 ALLOCATOR allocator)
2841 for (; !(begin == end); ++begin) {
2847template <
class VALUE_TYPE>
2848template <
class ALLOCATOR>
2855 const VALUE_TYPE& value,
2856 ALLOCATOR allocator)
2860 ALLOCATOR> ElementGuard;
2862 size_type frontSize = position - fromBegin;
2864 Iterator dest = begin - numElements;
2880 ElementGuard guard(dest, dest, allocator);
2881 if (frontSize >= numElements) {
2882 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
2888 for (frontSize -= numElements; 0 < frontSize;
2889 --frontSize, ++dest, ++begin) {
2892 for (numDest = numElements; 0 < numDest; --numDest, ++dest) {
2896 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
2902 for (numDest = numElements; frontSize < numDest; --numDest, ++dest) {
2908 for (; 0 < numDest; --numDest, ++dest) {
2913 *toBegin = fromBegin - numElements;
2916template <
class VALUE_TYPE>
2917template <
class FWD_ITER,
class ALLOCATOR>
2926 ALLOCATOR allocator)
2930 ALLOCATOR> ElementGuard;
2932 size_type frontSize = position - fromBegin;
2934 Iterator dest = begin - numElements;
2937 ElementGuard guard(dest, dest, allocator);
2938 if (frontSize >= numElements) {
2939 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++begin) {
2945 for (frontSize -= numElements; 0 < frontSize;
2946 --frontSize, ++dest, ++begin) {
2949 for (numDest = numElements; 0 < numDest; --numDest, ++dest, ++first) {
2953 for (numDest = frontSize; 0 < numDest; --numDest, ++dest, ++begin) {
2959 for (numDest = numElements; frontSize < numDest;
2960 --numDest, ++dest, ++first) {
2966 for (; 0 < numDest; --numDest, ++dest, ++first) {
2971 *toBegin = fromBegin - numElements;
2974template <
class VALUE_TYPE>
2975template <
class ALLOCATOR>
2982 const VALUE_TYPE& value,
2983 ALLOCATOR allocator)
2987 ALLOCATOR> ElementGuard;
2989 size_type backSize = fromEnd - position;
3007 ElementGuard guard(dest, dest, allocator);
3008 if (backSize >= numElements) {
3009 for (numDest = numElements; 0 < numDest; --numDest) {
3015 guard.moveBegin(-1);
3017 for (backSize -= numElements; 0 < backSize; --backSize) {
3022 for (numDest = numElements; 0 < numDest; --numDest, ++position) {
3023 *position = space.
object();
3026 for (numDest = backSize; 0 < numDest; --numDest) {
3032 guard.moveBegin(-1);
3034 for (numDest = numElements; backSize < numDest; --numDest) {
3039 guard.moveBegin(-1);
3041 for (; 0 < numDest; --numDest, ++position) {
3042 *position = space.
object();
3046 *toEnd = fromEnd + numElements;
3049template <
class VALUE_TYPE>
3050template <
class FWD_ITER,
class ALLOCATOR>
3058 ALLOCATOR allocator)
3062 ALLOCATOR> ElementGuard;
3064 size_type backSize = fromEnd - position;
3069 ElementGuard guard(dest, dest, allocator);
3070 if (backSize >= numElements) {
3071 for (numDest = numElements; 0 < numDest; --numDest) {
3077 guard.moveBegin(-1);
3079 for (numDest = backSize; numElements < numDest; --numDest) {
3084 for (; 0 < numDest; ++first, ++position, --numDest) {
3088 for (numDest = backSize; 0 < numDest; --numDest) {
3094 guard.moveBegin(-1);
3096 for (numDest = backSize; 0 < numDest; --numDest, ++position, ++first) {
3099 ElementGuard guard2(position, position, allocator);
3100 for (numDest = numElements; backSize < numDest; ++first, ++position,
3103 position.valuePtr(),
3110 *toEnd = fromEnd + numElements;
3113template <
class VALUE_TYPE>
3114template <
class ALLOCATOR>
3121 const VALUE_TYPE& value,
3122 ALLOCATOR allocator)
3129 IS_FUNDAMENTAL_OR_POINTER = IS_FUNDAMENTAL ||
3130 (IS_POINTER && !IS_FUNCTION_POINTER),
3134 VALUE = IS_FUNDAMENTAL_OR_POINTER || IS_BITWISECOPYABLE ?
3139 uninitializedFillNFront(toBegin,
3147template <
class VALUE_TYPE>
3148template <
class ALLOCATOR>
3154 const VALUE_TYPE& value,
3155 ALLOCATOR allocator,
3160 ALLOCATOR> ElementGuard;
3162 ElementGuard guard(fromBegin, fromBegin, allocator);
3163 for (; 0 < numElements; --numElements) {
3168 guard.moveBegin(-1);
3171 *toBegin = fromBegin;
3174template <
class VALUE_TYPE>
3175template <
class ALLOCATOR>
3181 const VALUE_TYPE& value,
3182 ALLOCATOR allocator,
3185 *toBegin = fromBegin;
3186 for ( ; 0 < numElements; --numElements) {
3192 *toBegin = fromBegin;
3196template <
class VALUE_TYPE>
3197template <
class ALLOCATOR>
3204 const VALUE_TYPE& value,
3205 ALLOCATOR allocator)
3212 IS_FUNDAMENTAL_OR_POINTER = IS_FUNDAMENTAL ||
3213 (IS_POINTER && !IS_FUNCTION_POINTER),
3217 VALUE = IS_FUNDAMENTAL_OR_POINTER || IS_BITWISECOPYABLE ?
3222 uninitializedFillNBack(toEnd,
3230template <
class VALUE_TYPE>
3231template <
class ALLOCATOR>
3237 const VALUE_TYPE& value,
3238 ALLOCATOR allocator,
3243 ALLOCATOR> ElementGuard;
3245 ElementGuard guard(fromEnd, fromEnd, allocator);
3246 for (; 0 < numElements; --numElements) {
3257template <
class VALUE_TYPE>
3258template <
class ALLOCATOR>
3264 const VALUE_TYPE& value,
3265 ALLOCATOR allocator,
3269 for ( ; 0 < numElements; --numElements) {
3279template <
class VALUE_TYPE>
3280template <
class ALLOCATOR>
3286 ALLOCATOR allocator)
3293 IS_FUNDAMENTAL_OR_POINTER = IS_FUNDAMENTAL ||
3294 (IS_POINTER && !IS_FUNCTION_POINTER),
3298 VALUE = IS_FUNDAMENTAL_OR_POINTER || IS_BITWISECOPYABLE ?
3303 valueInititalizeN(toEnd,
3310template <
class VALUE_TYPE>
3311template <
class ALLOCATOR>
3317 ALLOCATOR allocator,
3322 ALLOCATOR> ElementGuard;
3324 ElementGuard guard(fromEnd, fromEnd, allocator);
3325 for (; 0 < numElements; --numElements) {
3335template <
class VALUE_TYPE>
3336template <
class ALLOCATOR>
3342 ALLOCATOR allocator,
3346 for ( ; 0 < numElements; --numElements) {
3360template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3365 ALLOCATOR allocator)
3368, d_allocator(allocator)
3372template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3383template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3386<VALUE_TYPE, BLOCK_LENGTH, ALLOCATOR>::Iterator&
3394template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3397<VALUE_TYPE, BLOCK_LENGTH, ALLOCATOR>::Iterator&
3405template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
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>
3435 if (d_begin_p != d_end_p) {
3443template <
class VALUE_TYPE,
int BLOCK_LENGTH,
class ALLOCATOR>
3449 d_begin_p = d_end_p = 0;
3457template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3464: d_destination_p(dest)
3471template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3479 d_destination_p += d_size;
3480 d_source_p += d_size;
3485 d_destination_p -= d_size;
3486 d_source_p -= d_size;
3493template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3505template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3510: d_endpoint_p(endpoint)
3511, d_position(position)
3515template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3520 if (0 != d_endpoint_p) {
3521 *d_endpoint_p = d_position;
3526template <
class VALUE_TYPE,
int BLOCK_LENGTH>
3535#ifndef BDE_OPENSOURCE_PUBLICATION
3540#ifdef bslalg_DequePrimitives
3541#undef bslalg_DequePrimitives
3544#define bslalg_DequePrimitives bslalg::DequePrimitives
Definition bslalg_dequeiterator.h:337
VALUE_TYPE * valuePtr() const
Definition bslalg_dequeiterator.h:805
Definition bslalg_dequeiterator.h:157
void previousBlock()
Definition bslalg_dequeiterator.h:497
std::size_t offsetInBlock() const
Definition bslalg_dequeiterator.h:604
std::size_t remainingInBlock() const
Definition bslalg_dequeiterator.h:612
VALUE_TYPE * valuePtr() const
Definition bslalg_dequeiterator.h:620
void nextBlock()
Set this iterator to point to the first element of the next block.
Definition bslalg_dequeiterator.h:489
Definition bslalg_dequeprimitives.h:893
Iterator & moveEnd(std::ptrdiff_t offset=1)
Definition bslalg_dequeprimitives.h:3399
Iterator & moveBegin(std::ptrdiff_t offset=-1)
Definition bslalg_dequeprimitives.h:3388
void release()
Definition bslalg_dequeprimitives.h:3408
~DequePrimitives_DequeElementGuard()
Definition bslalg_dequeprimitives.h:3375
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:897
Definition bslalg_dequeprimitives.h:1069
void release()
Definition bslalg_dequeprimitives.h:3528
~DequePrimitives_DequeEndpointProctor()
Definition bslalg_dequeprimitives.h:3518
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:1073
Definition bslalg_dequeprimitives.h:1015
void release()
Set the size of the range guarded by this object to be zero.
Definition bslalg_dequeprimitives.h:3495
~DequePrimitives_DequeMoveGuard()
Definition bslalg_dequeprimitives.h:3474
bslalg::DequePrimitives< VALUE_TYPE, BLOCK_LENGTH > DequePrimitives
Definition bslalg_dequeprimitives.h:1020
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:1019
Definition bslalg_dequeprimitives.h:958
~DequePrimitives_ExternalDequeElementGuard()
Definition bslalg_dequeprimitives.h:3433
void release()
Definition bslalg_dequeprimitives.h:3447
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:962
Definition bslma_destructorproctor.h:259
Definition bslmf_movableref.h:751
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:289
Definition bdlc_flathashmap.h:1805
static void construct(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr, Args &&... arguments)
Definition bslma_allocatortraits.h:1472
static void destroy(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr)
Definition bslma_allocatortraits.h:1494
Definition bslmf_integralconstant.h:244
static void defaultConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2064
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:1905
Definition bslalg_dequeimputil.h:124
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:762
std::size_t size_type
Definition bslalg_dequeprimitives.h:761
DequeIterator< VALUE_TYPE, 1 > Iterator
Definition bslalg_dequeprimitives.h:763
Definition bslalg_dequeprimitives.h:243
static void moveBack(Iterator *destination, Iterator *source, size_type numElements)
Definition bslalg_dequeprimitives.h:2399
static void insertAndMoveToBack(Iterator *toEnd, Iterator fromEnd, Iterator position, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1281
static void insertAndMoveToFront(Iterator *toBegin, Iterator fromBegin, Iterator position, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1694
static void emplaceAndMoveToFrontDispatch(Iterator *toBegin, Iterator fromBegin, Iterator position, ALLOCATOR allocator, bsl::integral_constant< int, BITWISE_COPYABLE_TRAITS >, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2272
static void uninitializedFillNFront(Iterator *toBegin, Iterator fromBegin, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2746
static void uninitializedFillNBack(Iterator *toEnd, Iterator fromEnd, size_type numElements, const VALUE_TYPE &value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2653
static void moveInsertAndMoveToFront(Iterator *toBegin, Iterator fromBegin, Iterator position, bslmf::MovableRef< VALUE_TYPE > value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1944
static void emplaceAndMoveToBack(Iterator *toEnd, Iterator fromEnd, Iterator position, ALLOCATOR allocator, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2084
static void emplaceAndMoveToBackDispatch(Iterator *toEnd, Iterator fromEnd, Iterator position, ALLOCATOR allocator, bsl::integral_constant< int, BITWISE_COPYABLE_TRAITS >, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2112
std::size_t size_type
Definition bslalg_dequeprimitives.h:246
static void emplaceAndMoveToFront(Iterator *toBegin, Iterator fromBegin, Iterator position, ALLOCATOR allocator, Args &&... arguments)
Definition bslalg_dequeprimitives.h:2244
DequeIterator< VALUE_TYPE, BLOCK_LENGTH > Iterator
Definition bslalg_dequeprimitives.h:247
static void valueInititalizeN(Iterator *toEnd, Iterator fromEnd, size_type numElements, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:2702
static void moveInsertAndMoveToBack(Iterator *toEnd, Iterator fromEnd, Iterator position, bslmf::MovableRef< VALUE_TYPE > value, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1550
static Iterator erase(Iterator *toBegin, Iterator *toEnd, Iterator fromBegin, Iterator first, Iterator last, Iterator fromEnd, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1170
static void destruct(Iterator begin, Iterator end, ALLOCATOR allocator)
Definition bslalg_dequeprimitives.h:1122
static void moveFront(Iterator *destination, Iterator *source, size_type numElements)
Definition bslalg_dequeprimitives.h:2525
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1243
static Allocator * allocator(Allocator *basicAllocator=0)
Definition bslma_default.h:897
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_functionpointertraits.h:153
Definition bslmf_isfundamental.h:303
Definition bslmf_ispointer.h:225
Definition bslmf_movableref.h:791
Definition bsls_objectbuffer.h:276
TYPE & object()
Definition bsls_objectbuffer.h:351