8#ifndef INCLUDED_BSLSTL_LIST
9#define INCLUDED_BSLSTL_LIST
631#include <bslscm_version.h>
671#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
672#include <initializer_list>
677#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
681# define COMPILING_BSLSTL_LIST_H
683# undef COMPILING_BSLSTL_LIST_H
699template <
class VALUE>
708 template <
class LIST_VALUE,
class LIST_ALLOCATOR>
711 template <
class ITER_VALUE>
730#if defined(BSLS_LIBRARYFEATURES_STDCPP_LIBCSTD)
734template <
class VALUE>
736 public std::iterator<std::bidirectional_iterator_tag, VALUE> {
738template <
class VALUE>
752 template <
class LIST_VALUE,
class LIST_ALLOCATOR>
755 template <
class ITER_VALUE>
758 template <
class T1,
class T2>
805#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
867template <
class T1,
class T2>
870#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
871template <
class T1,
class T2>
892template <
class VALUE>
899 bool operator()(
const VALUE& lhs,
const VALUE& rhs)
const;
913template <
class VALUE,
class ALLOCATOR>
915 template rebind_traits<List_Node<VALUE> >::allocator_type {
925 typedef typename AllocTraits::allocator_type NodeAlloc;
927 typedef typename AllocTraits::size_type size_type;
962template <
class VALUE,
class ALLOCATOR>
973template <
class VALUE,
class ALLOCATOR>
990 typedef typename AllocTraits::pointer
NodePtr;
1032template <
class VALUE,
class ALLOCATOR = bsl::allocator<VALUE> >
1051 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
1059 typedef typename AllocTraits::allocator_type NodeAlloc;
1064 typedef typename AllocTraits::pointer NodePtr;
1096 NodeAlloc& allocatorImp();
1101 NodePtr allocateNode();
1107 void createSentinel();
1113 void deleteNode(NodePtr node);
1124 void freeNode(NodePtr node);
1136 void linkNodes(NodePtr prev, NodePtr next);
1150 template <
class COMPARE>
1151 NodePtr mergeImp(NodePtr node1,
1154 COMPARE comparator);
1160 void quickSwap(
list *other);
1175 template <class COMPARE>
1176 NodePtr sortImp(NodePtr *nodePtrPtr,
1178 const COMPARE& comparator);
1184 const NodeAlloc& allocatorImp() const;
1188 NodePtr headNode() const;
1192 const typename AllocTraits::
size_type& sizeRef() const
1206 explicit
list(const ALLOCATOR& basicAllocator);
1227 const ALLOCATOR& basicAllocator);
1243 const ALLOCATOR& basicAllocator = ALLOCATOR());
1266 template <class INPUT_ITERATOR>
1268 INPUT_ITERATOR last,
1269 const ALLOCATOR& basicAllocator = ALLOCATOR(),
1272 !
is_enum<INPUT_ITERATOR>::value
1274 : d_alloc_and_size(basicAllocator,
size_type(-1))
1285 list tmp(this->allocatorImp());
1314 list(BloombergLP::bslmf::MovableRef<list> original);
1326 list(BloombergLP::bslmf::MovableRef<list> original,
1329#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1330 list(std::initializer_list<value_type> values,
1331 const ALLOCATOR& basicAllocator = ALLOCATOR());
1366 list& operator=(BloombergLP::bslmf::MovableRef<list> rhs)
1368 AllocTraits::is_always_equal::value);
1383#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1392 list& operator=(std::initializer_list<value_type> rhs);
1409 template <
class INPUT_ITERATOR>
1411 INPUT_ITERATOR last,
1421 const iterator dstEnd = this->
end();
1423 for (; first != last && dstEnd != dstIt; ++first, ++dstIt) {
1427 erase(dstIt, dstEnd);
1429 for (; first != last; ++first) {
1430 emplace(dstEnd, *first);
1440#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1448 void assign(std::initializer_list<value_type> values);
1530#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1541 template <
class... ARGS>
1545#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1556 template <
class... ARGS>
1572 void push_back(BloombergLP::bslmf::MovableRef<value_type> value);
1586 void push_front(BloombergLP::bslmf::MovableRef<value_type> value);
1590#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1604 template <
class... ARGS>
1630 BloombergLP::bslmf::MovableRef<value_type> value);
1659 template <
class INPUT_ITERATOR>
1661 INPUT_ITERATOR first,
1662 INPUT_ITERATOR last,
1671 if (first == last) {
1672 return dstPosition.unconst();
1678 iterator ret = insert(dstPosition, *first);
1679 for (++first; first != last; ++first) {
1680 insert(dstPosition, *first);
1686#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1695 iterator insert(const_iterator dstPosition,
1696 std::initializer_list<value_type> values);
1709 void merge(BloombergLP::bslmf::MovableRef<list> other);
1718 template <
class COMPARE>
1720 template <
class COMPARE>
1721 void merge(BloombergLP::bslmf::MovableRef<list> other, COMPARE comparator);
1729 template <
class PREDICATE>
1749 template <class COMPARE>
1750 void sort(COMPARE comparator);
1760 BloombergLP::
bslmf::MovableRef<
list> src);
1774 BloombergLP::
bslmf::MovableRef<
list> src,
1792 BloombergLP::
bslmf::MovableRef<
list> src,
1803 template <class EQ_PREDICATE>
1804 void unique(EQ_PREDICATE binaryPredicate);
1809 AllocTraits::is_always_equal::value);
1890#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1902 class = bsl::enable_if_t<
1903 bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>,
1904 class = bsl::enable_if_t<
1905 bsl::is_convertible_v<
1914 class INPUT_ITERATOR,
1915 class VALUE =
typename
1916 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
1926 class INPUT_ITERATOR,
1928 class VALUE =
typename
1929 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1930 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>>
1938 class INPUT_ITERATOR,
1940 class VALUE =
typename
1941 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1943 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1945list(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1956 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1958list(std::initializer_list<VALUE>, ALLOC *)
1971template <
class VALUE,
class ALLOCATOR>
1975#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1977template <
class VALUE,
class ALLOCATOR>
1991#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1996template <
class VALUE,
class ALLOCATOR>
1997BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE> operator<=>(
2003template <
class VALUE,
class ALLOCATOR>
2018template <
class VALUE,
class ALLOCATOR>
2029template <
class VALUE,
class ALLOCATOR>
2040template <
class VALUE,
class ALLOCATOR>
2057template <
class VALUE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
2063template <
class VALUE,
class ALLOCATOR,
class PREDICATE>
2067template <
class VALUE,
class ALLOCATOR>
2094template <
class VALUE>
2098 return NcIter(d_node_p);
2102template <
class VALUE>
2109template <
class VALUE>
2116template <
class VALUE>
2119: d_node_p(other.d_node_p)
2124template <
class VALUE>
2128 this->d_node_p = this->d_node_p->d_next_p;
2132template <
class VALUE>
2136 this->d_node_p = this->d_node_p->d_prev_p;
2140template <
class VALUE>
2149template <
class VALUE>
2159template <
class VALUE>
2164 return this->d_node_p->d_value;
2167template <
class VALUE>
2172 return BloombergLP::bsls::Util::addressOf(this->d_node_p->d_value);
2176template <
class T1,
class T2>
2186 return lhs.d_node_p == rhs.d_node_p;
2189#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2190template <
class T1,
class T2>
2200 return ! (lhs == rhs);
2209template <
class VALUE,
class ALLOCATOR>
2212 const NodeAlloc& basicAllocator,
2214: NodeAlloc(basicAllocator)
2220template <
class VALUE,
class ALLOCATOR>
2222typename List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size_type&
2229template <
class VALUE,
class ALLOCATOR>
2231const typename List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size_type&
2242template <
class VALUE,
class ALLOCATOR>
2254template <
class VALUE,
class ALLOCATOR>
2259 d_list_p->freeNode(d_node_p);
2264template <
class VALUE,
class ALLOCATOR>
2276template <
class VALUE>
2279 const VALUE& lhs,
const VALUE& rhs)
const
2289template <
class VALUE,
class ALLOCATOR>
2291typename list<VALUE, ALLOCATOR>::NodeAlloc&
2294 return d_alloc_and_size;
2297template <
class VALUE,
class ALLOCATOR>
2299typename list<VALUE, ALLOCATOR>::NodePtr list<VALUE, ALLOCATOR>::allocateNode()
2301 NodePtr ret = AllocTraits::allocate(allocatorImp(), 1);
2307template <
class VALUE,
class ALLOCATOR>
2309void list<VALUE, ALLOCATOR>::createSentinel()
2313 d_sentinel = allocateNode();
2314 linkNodes(d_sentinel, d_sentinel);
2318template <
class VALUE,
class ALLOCATOR>
2320void list<VALUE, ALLOCATOR>::deleteNode(NodePtr node)
2324 AllocTraits::destroy(allocatorImp(),
2325 BloombergLP::bsls::Util::addressOf(node->d_value));
2326 AllocTraits::deallocate(allocatorImp(), node, 1);
2329template <
class VALUE,
class ALLOCATOR>
2331void list<VALUE, ALLOCATOR>::destroyAll()
2334 freeNode(d_sentinel);
2335 sizeRef() = size_type(-1);
2338template <
class VALUE,
class ALLOCATOR>
2340void list<VALUE, ALLOCATOR>::freeNode(NodePtr node)
2342 AllocTraits::deallocate(allocatorImp(), node, 1);
2345template <
class VALUE,
class ALLOCATOR>
2347typename list<VALUE, ALLOCATOR>::iterator
2348list<VALUE, ALLOCATOR>::insertNode(const_iterator position, NodePtr node)
2350 NodePtr next = position.d_node_p;
2351 NodePtr prev = next->d_prev_p;
2352 linkNodes(prev, node);
2353 linkNodes(node, next);
2355 return iterator(node);
2358template <
class VALUE,
class ALLOCATOR>
2360void list<VALUE, ALLOCATOR>::linkNodes(NodePtr prev, NodePtr next)
2362 prev->d_next_p = next;
2363 next->d_prev_p = prev;
2366template <
class VALUE,
class ALLOCATOR>
2367template <
class COMPARE>
2368typename list<VALUE, ALLOCATOR>::NodePtr
2374 NodePtr pre = node1->d_prev_p;
2388 while (node1 != node2 && node2 != finish) {
2394 if (comparator(node2->d_value, node1->d_value)) {
2400 NodePtr lastMove = node2;
2401 NodePtr next2 = node2->d_next_p;
2402 while (next2 != finish && comparator(next2->d_value,
2405 next2 = lastMove->d_next_p;
2408 linkNodes(node2->d_prev_p, next2);
2409 linkNodes(node1->d_prev_p, node2);
2410 linkNodes(lastMove, node1);
2419 node1 = node1->d_next_p;
2423 return pre->d_next_p;
2426template <
class VALUE,
class ALLOCATOR>
2434 swap(d_sentinel, other->d_sentinel);
2435 swap(sizeRef(), other->sizeRef());
2438template <
class VALUE,
class ALLOCATOR>
2440typename list<VALUE, ALLOCATOR>::AllocTraits::size_type&
2443 return d_alloc_and_size.
size();
2446template <
class VALUE,
class ALLOCATOR>
2447template <
class COMPARE>
2448typename list<VALUE, ALLOCATOR>::NodePtr
2451 const COMPARE& comparator)
2455 NodePtr node1 = *nodePtrPtr;
2457 return node1->d_next_p;
2462 NodePtr node2 = sortImp(&node1, half, comparator);
2463 NodePtr next = sortImp(&node2,
size - half, comparator);
2465 *nodePtrPtr = mergeImp(node1, node2, next, comparator);
2470template <
class VALUE,
class ALLOCATOR>
2472const typename list<VALUE, ALLOCATOR>::NodeAlloc&
2475 return d_alloc_and_size;
2478template <
class VALUE,
class ALLOCATOR>
2480typename list<VALUE, ALLOCATOR>::NodePtr list<VALUE, ALLOCATOR>::headNode()
2483 return d_sentinel->d_next_p;
2486template <
class VALUE,
class ALLOCATOR>
2488const typename list<VALUE, ALLOCATOR>::AllocTraits::size_type&
2491 return d_alloc_and_size.
size();
2495template <
class VALUE,
class ALLOCATOR>
2498, d_alloc_and_size(ALLOCATOR(), 0)
2501 typename AllocTraits::size_type>::value));
2503 typename AllocTraits::difference_type>::value));
2507template <
class VALUE,
class ALLOCATOR>
2510, d_alloc_and_size(basicAllocator, 0)
2515template <
class VALUE,
class ALLOCATOR>
2518, d_alloc_and_size(ALLOCATOR(),
size_type(-1))
2522 list tmp(this->allocatorImp());
2528 for (
size_type i = 0; i < numElements; ++i) {
2535template <
class VALUE,
class ALLOCATOR>
2537 const ALLOCATOR& basicAllocator)
2539, d_alloc_and_size(basicAllocator,
size_type(-1))
2543 list tmp(this->allocatorImp());
2549 for (
size_type i = 0; i < numElements; ++i) {
2556template <
class VALUE,
class ALLOCATOR>
2559 const ALLOCATOR& basicAllocator)
2561, d_alloc_and_size(basicAllocator,
size_type(-1))
2565 list tmp(this->allocatorImp());
2571template <
class VALUE,
class ALLOCATOR>
2575 AllocTraits::select_on_container_copy_construction(original.allocatorImp()),
2578 list tmp(this->allocatorImp());
2585template <
class VALUE,
class ALLOCATOR>
2589, d_alloc_and_size(basicAllocator,
size_type(-1))
2591 list tmp(this->allocatorImp());
2598template <
class VALUE,
class ALLOCATOR>
2601, d_alloc_and_size(MoveUtil::access(original).allocatorImp(), 0)
2612 quickSwap(&MoveUtil::access(original));
2615template <
class VALUE,
class ALLOCATOR>
2617 BloombergLP::bslmf::MovableRef<list> original,
2620, d_alloc_and_size(basicAllocator,
size_type(-1))
2624 list& lvalue = original;
2625 if (this->allocatorImp() == lvalue.allocatorImp()) {
2634 list tmp(this->allocatorImp());
2639 NodePtr endPtr = lvalue.d_sentinel;
2640 for (NodePtr p = lvalue.headNode(); endPtr != p; p = p->d_next_p) {
2650#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2651template <
class VALUE,
class ALLOCATOR>
2654 const ALLOCATOR& basicAllocator)
2655: d_alloc_and_size(basicAllocator, size_type(-1))
2663 list tmp(this->allocatorImp());
2664 tmp.insert(tmp.cbegin(), values.begin(), values.end());
2670template <
class VALUE,
class ALLOCATOR>
2685template <
class VALUE,
class ALLOCATOR>
2689 AllocTraits::propagate_on_container_copy_assignment Propagate;
2692 if (Propagate::value && allocatorImp() != rhs.allocatorImp()) {
2696 BloombergLP::bslma::AllocatorUtil::assign(&allocatorImp(),
2707template <
class VALUE,
class ALLOCATOR>
2709 BloombergLP::bslmf::MovableRef<list> rhs)
2713 AllocTraits::propagate_on_container_move_assignment Propagate;
2717 if (
this == &lvalue) {
2721 if (this->allocatorImp() == lvalue.allocatorImp()) {
2726 else if (Propagate::value) {
2740 list other(MoveUtil::move(lvalue));
2743 using BloombergLP::bslma::AllocatorUtil;
2745 AllocatorUtil::swap(
2746 &allocatorImp(), &other.allocatorImp(), Propagate());
2747 swap(d_sentinel, other.d_sentinel);
2748 swap(sizeRef(), other.sizeRef());
2756 NodePtr dstPtr = this->headNode();
2757 const const_iterator dstEnd = this->
cend();
2758 const NodePtr dstEndPtr = dstEnd.d_node_p;
2760 NodePtr srcPtr = lvalue.headNode();
2761 const NodePtr srcEndPtr = lvalue.d_sentinel;
2763 for (; srcEndPtr != srcPtr && dstEndPtr != dstPtr;
2764 srcPtr = srcPtr->d_next_p, dstPtr = dstPtr->d_next_p) {
2765 dstPtr->d_value = MoveUtil::move(srcPtr->d_value);
2768 erase(const_iterator(dstPtr), dstEnd);
2770 for (; srcEndPtr != srcPtr; srcPtr = srcPtr->d_next_p) {
2771 emplace(dstEnd, MoveUtil::move(srcPtr->d_value));
2778#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2779template <
class VALUE,
class ALLOCATOR>
2782 std::initializer_list<VALUE> rhs)
2784 assign(rhs.begin(), rhs.end());
2789template <
class VALUE,
class ALLOCATOR>
2792 NodePtr dst_p = this->headNode();
2794 const NodePtr dstEnd_p = dstEnd.d_node_p;
2796 for (; 0 < numElements && dstEnd_p != dst_p;
2797 --numElements, dst_p = dst_p->d_next_p) {
2798 dst_p->d_value = value;
2803 for (; 0 < numElements; --numElements) {
2804 insert(dstEnd, value);
2808#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2809template <
class VALUE,
class ALLOCATOR>
2813 assign(values.begin(), values.end());
2819template <
class VALUE,
class ALLOCATOR>
2824 return iterator(headNode());
2827template <
class VALUE,
class ALLOCATOR>
2835template <
class VALUE,
class ALLOCATOR>
2843template <
class VALUE,
class ALLOCATOR>
2853template <
class VALUE,
class ALLOCATOR>
2857 const NodePtr e = d_sentinel;
2858 for (NodePtr p = d_sentinel->d_next_p; e != p; ) {
2859 NodePtr condemned = p;
2861 deleteNode(condemned);
2864 linkNodes(d_sentinel, d_sentinel);
2868template <
class VALUE,
class ALLOCATOR>
2871 if (newSize > sizeRef()) {
2875 }
while (newSize > sizeRef());
2878 NodePtr e = d_sentinel;
2879 NodePtr p = e->d_prev_p;
2880 for (
size_type d = sizeRef() - newSize; d > 0; --d) {
2881 NodePtr condemned = p;
2883 deleteNode(condemned);
2886 sizeRef() = newSize;
2890template <
class VALUE,
class ALLOCATOR>
2893 if (newSize > sizeRef()) {
2897 }
while (newSize > sizeRef());
2900 NodePtr e = d_sentinel;
2901 NodePtr p = e->d_prev_p;
2902 for (
size_type d = sizeRef() - newSize; d > 0; --d) {
2903 NodePtr condemned = p;
2905 deleteNode(condemned);
2908 sizeRef() = newSize;
2914template <
class VALUE,
class ALLOCATOR>
2921 return d_sentinel->d_prev_p->d_value;
2924template <
class VALUE,
class ALLOCATOR>
2931 return headNode()->d_value;
2936template <
class VALUE,
class ALLOCATOR>
2945template <
class VALUE,
class ALLOCATOR>
2956template <
class VALUE,
class ALLOCATOR>
2962 NodePtr condemned = position.d_node_p;
2965 linkNodes(condemned->d_prev_p, condemned->d_next_p);
2966 deleteNode(condemned);
2971template <
class VALUE,
class ALLOCATOR>
2975 NodePtr p = dstBegin.d_node_p;
2976 const NodePtr e = dstEnd. d_node_p;
2978 linkNodes(p->d_prev_p, e);
2981 for (; e != p; ++numDeleted) {
2982 NodePtr condemned = p;
2984 deleteNode(condemned);
2987 sizeRef() -= numDeleted;
2994#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2995template <
class VALUE,
class ALLOCATOR>
2996template <
class... ARGS>
3006#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3007template <
class VALUE,
class ALLOCATOR>
3008template <
class... ARGS>
3018template <
class VALUE,
class ALLOCATOR>
3022 emplace(
cend(), value);
3025template <
class VALUE,
class ALLOCATOR>
3028 BloombergLP::bslmf::MovableRef<VALUE> value)
3030 emplace(
cend(), MoveUtil::move(value));
3033template <
class VALUE,
class ALLOCATOR>
3037 emplace(
cbegin(), value);
3040template <
class VALUE,
class ALLOCATOR>
3043 BloombergLP::bslmf::MovableRef<VALUE> value)
3045 emplace(
cbegin(), MoveUtil::move(value));
3050#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3051template <
class VALUE,
class ALLOCATOR>
3052template <
class... ARGS>
3056 NodePtr p = allocateNode();
3058 AllocTraits::construct(allocatorImp(),
3059 BloombergLP::bsls::Util::addressOf(p->d_value),
3062 return insertNode(position, p);
3066template <
class VALUE,
class ALLOCATOR>
3070 return emplace(dstPosition, value);
3073template <
class VALUE,
class ALLOCATOR>
3077 BloombergLP::bslmf::MovableRef<VALUE> value)
3079 return emplace(dstPosition, MoveUtil::move(value));
3082template <
class VALUE,
class ALLOCATOR>
3088 if (0 == numElements) {
3089 return dstPosition.unconst();
3094 iterator ret = emplace(dstPosition, value);
3098 for (--numElements; numElements > 0; --numElements) {
3099 emplace(dstPosition, value);
3105#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3106template <
class VALUE,
class ALLOCATOR>
3109 std::initializer_list<VALUE> values)
3111 return insert(dstPosition, values.begin(), values.end());
3117template <
class VALUE,
class ALLOCATOR>
3126template <
class VALUE,
class ALLOCATOR>
3130 list& lvalue = other;
3137template <
class VALUE,
class ALLOCATOR>
3138template <
class COMPARE>
3141 if (&other ==
this) {
3145 BSLS_ASSERT(this->allocatorImp() == other.allocatorImp());
3147 if (other.
empty()) {
3156 NodePtr xfirst = other.d_sentinel->d_next_p;
3157 splice(
end(), other);
3163 mergeImp(d_sentinel->d_next_p, xfirst, d_sentinel, comparator);
3166template <
class VALUE,
class ALLOCATOR>
3167template <
class COMPARE>
3170 BloombergLP::bslmf::MovableRef<list> other,
3173 list& lvalue = other;
3177 merge(lvalue, comparator);
3180template <
class VALUE,
class ALLOCATOR>
3185 const const_iterator e =
cend();
3197 return origSize - this->
size();
3200template <
class VALUE,
class ALLOCATOR>
3201template <
class PREDICATE>
3206 const iterator e =
end();
3208 if (predicate(*i)) {
3216 return origSize - this->
size();
3219template <
class VALUE,
class ALLOCATOR>
3222 NodePtr sentinel = d_sentinel;
3223 NodePtr p = sentinel;
3226 NodePtr tmp = p->d_next_p;
3227 p->d_next_p = p->d_prev_p;
3230 }
while (p != sentinel);
3233template <
class VALUE,
class ALLOCATOR>
3240template <
class VALUE,
class ALLOCATOR>
3241template <
class COMPARE>
3244 if (sizeRef() < 2) {
3247 NodePtr node1 = d_sentinel->d_next_p;
3248 sortImp(&node1,
size(), comparator);
3251template <
class VALUE,
class ALLOCATOR>
3254 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
3261 NodePtr pPos = dstPosition.d_node_p;
3262 NodePtr pFirst = src.headNode();
3263 NodePtr pLast = src.d_sentinel->d_prev_p;
3268 linkNodes(src.d_sentinel, src.d_sentinel);
3273 linkNodes(pPos->d_prev_p, pFirst);
3274 linkNodes(pLast, pPos);
3278template <
class VALUE,
class ALLOCATOR>
3282 BloombergLP::bslmf::MovableRef<list> src)
3284 splice(dstPosition, MoveUtil::access(src));
3287template <
class VALUE,
class ALLOCATOR>
3292 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
3294 NodePtr pPos = dstPosition.d_node_p;
3295 NodePtr pSrcNode = srcNode.d_node_p;
3296 NodePtr pAfterSrcNode = pSrcNode->d_next_p;
3298 if (pPos == pSrcNode || pPos == pAfterSrcNode) {
3304 linkNodes(pSrcNode->d_prev_p, pAfterSrcNode);
3309 linkNodes(pPos->d_prev_p, pSrcNode);
3310 linkNodes(pSrcNode, pPos);
3314template <
class VALUE,
class ALLOCATOR>
3318 BloombergLP::bslmf::MovableRef<list> src,
3321 splice(dstPosition, MoveUtil::access(src), srcNode);
3324template <
class VALUE,
class ALLOCATOR>
3330 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
3332 size_type n = bsl::distance(first, last);
3338 NodePtr pPos = dstPosition.d_node_p;
3339 NodePtr pFirst = first.d_node_p;
3340 NodePtr pLast = last.d_node_p;
3341 NodePtr pSrcLast = pLast->d_prev_p;
3345 linkNodes(pFirst->d_prev_p, pLast);
3350 linkNodes(pPos->d_prev_p, pFirst);
3351 linkNodes(pSrcLast, pPos);
3355template <
class VALUE,
class ALLOCATOR>
3359 BloombergLP::bslmf::MovableRef<list> src,
3363 splice(dstPosition, MoveUtil::access(src), first, last);
3366template <
class VALUE,
class ALLOCATOR>
3377 while (i != e && *i == match) {
3383template <
class VALUE,
class ALLOCATOR>
3384template <
class EQ_PREDICATE>
3395 while (i != e && binaryPredicate(*i, match)) {
3403template <
class VALUE,
class ALLOCATOR>
3410 typedef typename AllocTraits::propagate_on_container_swap Propagate;
3412 if (Propagate::value) {
3414 using BloombergLP::bslma::AllocatorUtil;
3416 AllocatorUtil::swap(
3417 &allocatorImp(), &other.allocatorImp(), Propagate());
3418 swap(d_sentinel, other.d_sentinel);
3419 swap(sizeRef(), other.sizeRef());
3422 allocatorImp() == other.allocatorImp())) {
3436 list toOtherCopy(MoveUtil::move(*
this), other.allocatorImp());
3437 list toThisCopy( MoveUtil::move(other), this->allocatorImp());
3439 toOtherCopy.quickSwap(&other);
3440 toThisCopy .quickSwap(
this);
3448template <
class VALUE,
class ALLOCATOR>
3450typename list<VALUE, ALLOCATOR>::const_iterator
3453 return const_iterator(headNode());
3456template <
class VALUE,
class ALLOCATOR>
3458typename list<VALUE, ALLOCATOR>::const_iterator
3464template <
class VALUE,
class ALLOCATOR>
3472template <
class VALUE,
class ALLOCATOR>
3480template <
class VALUE,
class ALLOCATOR>
3488template <
class VALUE,
class ALLOCATOR>
3496template <
class VALUE,
class ALLOCATOR>
3504template <
class VALUE,
class ALLOCATOR>
3514template <
class VALUE,
class ALLOCATOR>
3518 return 0 == sizeRef();
3521template <
class VALUE,
class ALLOCATOR>
3526 return AllocTraits::max_size(allocatorImp());
3529template <
class VALUE,
class ALLOCATOR>
3539template <
class VALUE,
class ALLOCATOR>
3546 return d_sentinel->d_prev_p->d_value;
3549template <
class VALUE,
class ALLOCATOR>
3556 return headNode()->d_value;
3561template <
class VALUE,
class ALLOCATOR>
3565 return allocatorImp();
3571template <
class VALUE,
class ALLOCATOR>
3573bool bsl::operator==(
const list<VALUE, ALLOCATOR>& lhs,
3574 const list<VALUE, ALLOCATOR>& rhs)
3576 return BloombergLP::bslalg::RangeCompare::equal(lhs.begin(),
3584#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
3586template <
class VALUE,
class ALLOCATOR>
3589 const list<VALUE, ALLOCATOR>& rhs)
3591 return ! (lhs == rhs);
3596#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
3598template <
class VALUE,
class ALLOCATOR>
3600BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE> bsl::operator<=>(
3601 const list<VALUE, ALLOCATOR>& lhs,
3602 const list<VALUE, ALLOCATOR>& rhs)
3604 return bsl::lexicographical_compare_three_way(
3609 BloombergLP::bslalg::SynthThreeWayUtil::compare);
3614template <
class VALUE,
class ALLOCATOR>
3616bool bsl::operator< (
const list<VALUE, ALLOCATOR>& lhs,
3617 const list<VALUE, ALLOCATOR>& rhs)
3619 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.begin(),
3627template <
class VALUE,
class ALLOCATOR>
3629bool bsl::operator> (
const list<VALUE, ALLOCATOR>& lhs,
3630 const list<VALUE, ALLOCATOR>& rhs)
3635template <
class VALUE,
class ALLOCATOR>
3638 const list<VALUE, ALLOCATOR>& rhs)
3640 return !(rhs < lhs);
3643template <
class VALUE,
class ALLOCATOR>
3646 const list<VALUE, ALLOCATOR>& rhs)
3648 return !(lhs < rhs);
3654template <
class VALUE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
3656bsl::erase(list<VALUE, ALLOCATOR>& l,
const BDE_OTHER_TYPE& value)
3661 typename list<VALUE, ALLOCATOR>::size_type oldSize = l.
size();
3662 for (
typename list<VALUE, ALLOCATOR>::iterator it = l.begin();
3672 return oldSize - l.size();
3675template <
class VALUE,
class ALLOCATOR,
class PREDICATE>
3677bsl::erase_if(list<VALUE, ALLOCATOR>& l, PREDICATE predicate)
3679 return BloombergLP::bslstl::AlgorithmUtil::containerEraseIf(l, predicate);
3682template <
class VALUE,
class ALLOCATOR>
3684void bsl::swap(list<VALUE, ALLOCATOR>& a, list<VALUE, ALLOCATOR>& b)
3704template <
class VALUE,
class ALLOCATOR>
3713template <
class VALUE,
class ALLOCATOR>
3724template <
class VALUE,
class ALLOCATOR>
3726 : BloombergLP::bslmf::IsBitwiseMoveable<ALLOCATOR>
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements contained by this deque.
Definition bslstl_deque.h:2074
Definition bslstl_list.h:915
List_AllocAndSizeWrapper(const NodeAlloc &basicAllocator, size_type size)
Definition bslstl_list.h:2211
size_type & size()
Definition bslstl_list.h:2223
const size_type & size() const
Definition bslstl_list.h:2232
Definition bslstl_list.h:739
List_Iterator & operator--()
Definition bslstl_list.h:2134
friend class list
Definition bslstl_list.h:753
VALUE * pointer
Definition bslstl_list.h:773
List_Iterator & operator++()
Definition bslstl_list.h:2126
friend class List_Iterator
Definition bslstl_list.h:756
reference operator*() const
Definition bslstl_list.h:2162
friend bool operator==(List_Iterator< T1 >, List_Iterator< T2 >)
Definition bslstl_list.h:2178
std::bidirectional_iterator_tag iterator_category
Definition bslstl_list.h:770
VALUE & reference
Definition bslstl_list.h:774
NcType value_type
Definition bslstl_list.h:771
BloombergLP::bsls::Types::IntPtr difference_type
Definition bslstl_list.h:772
pointer operator->() const
Definition bslstl_list.h:2170
Definition bslstl_list.h:974
AllocTraits::pointer NodePtr
Definition bslstl_list.h:990
void release()
Definition bslstl_list.h:2266
~List_NodeProctor()
Definition bslstl_list.h:2256
Definition bslstl_list.h:700
Definition bslma_bslallocator.h:580
Forward declaration required by List_NodeProctor.
Definition bslstl_list.h:1033
void reverse() BSLS_KEYWORD_NOEXCEPT
Reverse the order of the elements in this list.
Definition bslstl_list.h:3220
void resize(size_type newSize)
Definition bslstl_list.h:2869
list(const list &original, const typename type_identity< ALLOCATOR >::type &basicAllocator)
Definition bslstl_list.h:2586
void merge(BloombergLP::bslmf::MovableRef< list > other)
Definition bslstl_list.h:3128
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3563
const VALUE & const_reference
Definition bslstl_list.h:1069
list(const list &original)
Definition bslstl_list.h:2572
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3491
void push_back(BloombergLP::bslmf::MovableRef< value_type > value)
Definition bslstl_list.h:3027
VALUE & reference
Definition bslstl_list.h:1068
list(BloombergLP::bslmf::MovableRef< list > original, const typename type_identity< ALLOCATOR >::type &basicAllocator)
Definition bslstl_list.h:2616
iterator insert(const_iterator dstPosition, const value_type &value)
Definition bslstl_list.h:3068
void merge(BloombergLP::bslmf::MovableRef< list > other, COMPARE comparator)
Definition bslstl_list.h:3169
void merge(list &other)
Definition bslstl_list.h:3119
reference back()
Definition bslstl_list.h:2917
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3475
void push_front(BloombergLP::bslmf::MovableRef< value_type > value)
Definition bslstl_list.h:3042
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3483
list()
Definition bslstl_list.h:2496
void sort()
Definition bslstl_list.h:3235
allocator_traits< ALLOCATOR >::size_type size_type
Definition bslstl_list.h:1076
List_Iterator< VALUE > iterator
Definition bslstl_list.h:1070
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_list.h:1082
size_type remove_if(PREDICATE predicate)
void unique()
Definition bslstl_list.h:3367
void swap(list &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocTraits const_iterator begin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:1829
size_type remove(const value_type &value)
Definition bslstl_list.h:3182
void pop_front()
Definition bslstl_list.h:2947
list(BloombergLP::bslmf::MovableRef< list > original)
Definition bslstl_list.h:2599
size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3524
iterator begin() BSLS_KEYWORD_NOEXCEPT
allocator_traits< ALLOCATOR >::pointer pointer
Definition bslstl_list.h:1072
void push_back(const value_type &value)
Definition bslstl_list.h:3020
iterator insert(const_iterator dstPosition, BloombergLP::bslmf::MovableRef< value_type > value)
Definition bslstl_list.h:3075
iterator insert(const_iterator dstPosition, size_type numElements, const value_type &value)
Definition bslstl_list.h:3084
VALUE value_type
Definition bslstl_list.h:1079
void pop_back()
Definition bslstl_list.h:2938
allocator_traits< ALLOCATOR >::difference_type difference_type
Definition bslstl_list.h:1078
List_Iterator< const VALUE > const_iterator
Definition bslstl_list.h:1071
allocator_traits< ALLOCATOR >::const_pointer const_pointer
Definition bslstl_list.h:1074
list & operator=(const list &rhs)
Definition bslstl_list.h:2686
void push_front(const value_type &value)
Definition bslstl_list.h:3035
iterator insert(const_iterator dstPosition, INPUT_ITERATOR first, INPUT_ITERATOR last, typename enable_if< !is_arithmetic< INPUT_ITERATOR >::value &&!is_enum< INPUT_ITERATOR >::value >::type *=0)
Definition bslstl_list.h:1660
iterator emplace(const_iterator position, ARGS &&... arguments)
reference emplace_front(ARGS &&... arguments)
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:2846
void splice(const_iterator dstPosition, list &src)
Definition bslstl_list.h:3252
reference emplace_back(ARGS &&... arguments)
~list()
Definition bslstl_list.h:2671
reference front()
Definition bslstl_list.h:2927
ALLOCATOR allocator_type
Definition bslstl_list.h:1080
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this list.
Definition bslstl_list.h:3531
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:2838
list &operator=(BloombergLP::bslmf::MovableRef< list > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocTraits void assign(INPUT_ITERATOR first, INPUT_ITERATOR last, typename enable_if< !is_arithmetic< INPUT_ITERATOR >::value &&!is_enum< INPUT_ITERATOR >::value >::type *=0)
Definition bslstl_list.h:1410
iterator erase(const_iterator position)
Definition bslstl_list.h:2958
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:2829
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this list has no elements, and false otherwise.
Definition bslstl_list.h:3516
void clear() BSLS_KEYWORD_NOEXCEPT
Remove all the elements from this list.
Definition bslstl_list.h:2855
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3467
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_list.h:1081
void merge(list &other, COMPARE comparator)
Definition bslstl_list.h:3139
void assign(size_type numElements, const value_type &value)
Definition bslstl_list.h:2790
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#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_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:635
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
void swap(OptionValue &a, OptionValue &b)
int assign(LHS_TYPE *lhs, const RHS_TYPE &rhs)
Definition bdlb_printmethods.h:283
T::reverse_iterator rend(T &container)
Definition bslstl_iterator.h:1625
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
T::const_iterator cend(const T &container)
Definition bslstl_iterator.h:1611
T::const_reverse_iterator crbegin(const T &container)
Definition bslstl_iterator.h:1597
T::reverse_iterator rbegin(T &container)
Definition bslstl_iterator.h:1567
bool operator>=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator<=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4126
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::const_iterator cbegin(const T &container)
Definition bslstl_iterator.h:1553
BSLS_KEYWORD_CONSTEXPR size_t size(const TYPE(&)[DIMENSION]) BSLS_KEYWORD_NOEXCEPT
Return the dimension of the specified array argument.
Definition bslstl_iterator.h:1331
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4135
bool operator!=(const memory_resource &a, const memory_resource &b)
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1279
T::const_reverse_iterator crend(const T &container)
Definition bslstl_iterator.h:1654
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
void swap(TYPE &a, TYPE &b)
Definition bslstl_list.h:893
bool operator()(const VALUE &lhs, const VALUE &rhs) const
Definition bslstl_list.h:2278
Definition bslma_allocatortraits.h:1061
BloombergLP::bslma::AllocatorTraits_ConstPointerType< ALLOCATOR_TYPE >::type const_pointer
Definition bslma_allocatortraits.h:1152
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR_TYPE >::type size_type
Definition bslma_allocatortraits.h:1165
BloombergLP::bslma::AllocatorTraits_PointerType< ALLOCATOR_TYPE >::type pointer
Definition bslma_allocatortraits.h:1149
BloombergLP::bslma::AllocatorTraits_DifferenceType< ALLOCATOR_TYPE >::type difference_type
Definition bslma_allocatortraits.h:1162
Definition bslmf_enableif.h:525
Definition bslmf_isarithmetic.h:124
Definition bslmf_isconvertible.h:867
Definition bslmf_isenum.h:270
Definition bslmf_issame.h:146
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126
t_TYPE type
Definition bslmf_typeidentity.h:216
Definition bslalg_hasstliterators.h:99
Definition bslma_usesbslmaallocator.h:343
Definition bslmf_isbitwisemoveable.h:718