8#ifndef INCLUDED_BSLSTP_SLIST
9#define INCLUDED_BSLSTP_SLIST
100#ifdef BDE_OPENSOURCE_PUBLICATION
101#error "bslstp_slist is not for publication"
168template <
class _Tp,
class _Traits>
207template <
class _Tp,
class _Alloc>
227 BloombergLP::bslma::DestructionUtil::destroy(
229 _M_head.allocatorRef().deallocate(__next,1);
237 return _M_head.get_allocator();
242template <
class _Tp,
class _Alloc = bsl::allocator<_Tp> >
262 typedef BloombergLP::bslalg::ScalarPrimitives primitive;
289 _Node* __node = this->
_M_head.allocatorRef().allocate(1);
291 typedef BloombergLP::bslma::ConstructionUtil Util;
293 this->get_allocator(),
298 this->
_M_head.allocatorRef().deallocate(__node, 1);
312 { _M_insert_after_fill(&this->
_M_head._M_data, __n, __x); }
317 template <
class _InputIterator>
318 slist(_InputIterator __first, _InputIterator __last,
321 { _M_insert_after_range(&this->
_M_head._M_data, __first, __last); }
356 template <
class _InputIterator>
357 void assign(_InputIterator __first, _InputIterator __last) {
363 template <
class _Integer>
367 template <
class _InputIter>
372 while (__node != 0 && __first != __last) {
378 if (__first != __last)
379 _M_insert_after_range(__prev, __first, __last);
411 BloombergLP::bslstp::Util::swapContainers(*
this, __x,
QuickSwap());
417 {
return ((
_Node*) this->
_M_head._M_data._M_next)->_M_data; }
425 BloombergLP::bslma::DestructionUtil::destroy(
427 this->
_M_head.allocatorRef().deallocate(__node, 1);
438 _Node* _M_insert_after(_Node_base* __pos,
const value_type& __x = _Tp()) {
443 void _M_insert_after_fill(_Node_base *__pos,
445 for (
size_type __i = 0; __i < __n; ++__i)
450 template <
class _InIter>
451 void _M_insert_after_range(_Node_base *__pos,
452 _InIter __first, _InIter __last) {
457 template <
class _Integer>
458 void _M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x,
460 _M_insert_after_fill(__pos, __n, __x);
463 template <
class _InIter>
464 void _M_insert_after_range(_Node_base *__pos,
465 _InIter __first, _InIter __last,
467 while (__first != __last) {
482 _M_insert_after_fill(__pos.
_M_node, __n, __x);
487 template <
class _InIter>
489 _M_insert_after_range(__pos.
_M_node, __first, __last);
506 template <
class _InIter>
508 _M_insert_after_range(
546 if (__before_first != __before_last) {
570 if (__x.
_M_head._M_data._M_next)
587 if (__first != __last)
595 if (this->
_M_head._M_data._M_next)
599 void remove(
const _Tp& __val);
601 void merge(_Self& __x);
604 template <
class _Predicate>
615 template <
class _BinaryPredicate>
620 if (__pred(((
_Node*)__cur)->_M_data,
629 template <
class _StrictWeakOrdering>
631 _StrictWeakOrdering __comp) {
634 if (__comp(((
_Node*) __x.
_M_head._M_data._M_next)->_M_data,
639 if (__x.
_M_head._M_data._M_next) {
641 __x.
_M_head._M_data._M_next = 0;
645 template <
class _StrictWeakOrdering>
646 void sort(_StrictWeakOrdering __comp) {
647 if (this->
_M_head._M_data._M_next && this->_M_head._M_data._M_next->_M_next) {
656 BloombergLP::bsls::ObjectBuffer<_Self> __counterBuffers[64];
657 _Self* __counter = &__counterBuffers[0].object();
658 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
659 __counter, 64, __carry,
661 BloombergLP::bslma::AutoDestructor<_Self> __counterGuard(__counter, 64);
667 while (__i < __fill && !__counter[__i].
empty()) {
668 __counter[__i].
merge(__carry, __comp);
669 __carry.
swap(__counter[__i]);
672 __carry.
swap(__counter[__i]);
677 for (
int __i = 1; __i < __fill; ++__i)
678 __counter[__i].
merge(__counter[__i-1], __comp);
679 this->
swap(__counter[__fill-1]);
685template <
class _Tp,
class _Alloc>
690 const_iterator __end1 = _SL1.
end();
691 const_iterator __end2 = _SL2.
end();
693 const_iterator __i1 = _SL1.
begin();
694 const_iterator __i2 = _SL2.
begin();
695 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
699 return __i1 == __end1 && __i2 == __end2;
702template <
class _Tp,
class _Alloc>
706 return std::lexicographical_compare(__x.
begin(), __x.
end(),
710template <
class _Tp,
class _Alloc>
715template <
class _Tp,
class _Alloc>
720template <
class _Tp,
class _Alloc>
725template <
class _Tp,
class _Alloc>
776template <
class _Tp,
class _Alloc>
781 while (__cur != __last_node) {
784 BloombergLP::bslma::DestructionUtil::destroy(
786 _M_head.allocatorRef().deallocate(__tmp,1);
788 __before_first->
_M_next = __last_node;
792template <
class _Tp,
class _Alloc>
799 while (__n1 && __n2) {
806 this->_M_erase_after(__p1, 0);
814template <
class _Tp,
class _Alloc>
818 for ( ; __node != 0 && __n > 0 ; --__n) {
824 _M_insert_after_fill(__prev, __n, __val);
826 this->_M_erase_after(__prev, 0);
830template <
class _Tp,
class _Alloc>
834 while (__cur->
_M_next != 0 && __len > 0) {
839 this->_M_erase_after(__cur, 0);
841 _M_insert_after_fill(__cur, __len, __x);
844template <
class _Tp,
class _Alloc>
848 while (__cur && __cur->
_M_next) {
850 this->_M_erase_after(__cur);
856template <
class _Tp,
class _Alloc>
862 if (((
_Node*)__cur)->_M_data ==
864 this->_M_erase_after(__cur);
871template <
class _Tp,
class _Alloc>
881 if (__x.
_M_head._M_data._M_next) {
883 __x.
_M_head._M_data._M_next = 0;
887template <
class _Tp,
class _Alloc>
890 if (this->_M_head._M_data._M_next && this->_M_head._M_data._M_next->_M_next) {
891 _Self __carry(this->get_allocator());
899 BloombergLP::bsls::ObjectBuffer<_Self> __counterBuffers[64];
900 _Self* __counter = &__counterBuffers[0].object();
902 this->get_allocator());
903 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
904 __counter, 64, __carry,
906 BloombergLP::bslma::AutoDestructor<_Self> __counterGuard(__counter, 64);
912 while (__i < __fill && !__counter[__i].
empty()) {
913 __counter[__i].
merge(__carry);
914 __carry.
swap(__counter[__i]);
917 __carry.
swap(__counter[__i]);
922 for (
int __i = 1; __i < __fill; ++__i)
923 __counter[__i].merge(__counter[__i-1]);
924 this->swap(__counter[__fill-1]);
951template <
class _Tp,
class _Alloc>
952class insert_iterator<
bsl::slist<_Tp, _Alloc> > {
967 if (__i == __x.
begin())
973 insert_iterator<_Container>&
978 insert_iterator<_Container>&
operator*() {
return *
this; }
980 insert_iterator<_Container>&
operator++(
int) {
return *
this; }
Definition bslstp_alloc.h:105
static void __splice_after(_Slist_node_base *__pos, _Slist_node_base *__before_first, _Slist_node_base *__before_last)
Definition bslstp_slistbase.h:188
static std::size_t size(_Slist_node_base *__node)
Definition bslstp_slistbase.h:219
static _Slist_node_base * __previous(_Slist_node_base *__head, const _Slist_node_base *__node)
Definition bslstp_slistbase.h:165
static _Slist_node_base * __reverse(_Slist_node_base *__node)
Definition bslstp_slistbase.h:203
Definition bslstp_slist.h:244
void splice(iterator __pos, _Self &__x, iterator __first, iterator __last)
Definition bslstp_slist.h:585
const_reference front() const
Definition bslstp_slist.h:416
void swap(_Self &__x)
Definition bslstp_slist.h:410
value_type & reference
Definition bslstp_slist.h:271
void merge(_Self &__x)
Definition bslstp_slist.h:872
_Tp value_type
Definition bslstp_slist.h:268
void unique()
Definition bslstp_slist.h:857
std::ptrdiff_t difference_type
Definition bslstp_slist.h:274
iterator end()
Definition bslstp_slist.h:401
iterator erase_after(iterator __before_first, iterator __last)
Definition bslstp_slist.h:519
iterator before_begin()
Definition bslstp_slist.h:393
void insert(iterator __pos, size_type __n, const value_type &__x)
Definition bslstp_slist.h:500
void reverse()
Definition bslstp_slist.h:594
void splice_after(iterator __pos, iterator __before_first, iterator __before_last)
Definition bslstp_slist.h:543
void remove_if(_Predicate __pred)
Definition bslstp_slist.h:605
_Self & operator=(const _Self &__x)
Definition bslstp_slist.h:793
const value_type * const_pointer
Definition bslstp_slist.h:270
reference front()
Definition bslstp_slist.h:415
bool empty() const
Definition bslstp_slist.h:408
size_type size() const
Definition bslstp_slist.h:404
iterator begin()
Definition bslstp_slist.h:397
iterator insert(iterator __pos, const value_type &__x=_Tp())
Definition bslstp_slist.h:493
void sort(_StrictWeakOrdering __comp)
Definition bslstp_slist.h:646
void insert_after(iterator __pos, _InIter __first, _InIter __last)
Definition bslstp_slist.h:488
iterator insert_after(iterator __pos, const value_type &__x=_Tp())
Definition bslstp_slist.h:476
slist(const _Self &__x)
Definition bslstp_slist.h:323
const_iterator end() const
Definition bslstp_slist.h:402
void splice_after(iterator __pos, _Self &__x)
Definition bslstp_slist.h:563
iterator erase(iterator __pos)
Definition bslstp_slist.h:524
void _M_fill_assign(size_type __n, const _Tp &__val)
Definition bslstp_slist.h:815
void insert_after(iterator __pos, size_type __n, const value_type &__x)
Definition bslstp_slist.h:481
slist(const allocator_type &__a=allocator_type())
Definition bslstp_slist.h:307
void unique(_BinaryPredicate __pred)
Definition bslstp_slist.h:616
iterator erase(iterator __first, iterator __last)
Definition bslstp_slist.h:529
_Base::allocator_type allocator_type
Definition bslstp_slist.h:280
allocator_type get_allocator() const
Definition bslstp_slist.h:305
slist(size_type __n, const value_type &__x=_Tp(), const allocator_type &__a=allocator_type())
Definition bslstp_slist.h:309
void merge(slist< _Tp, _Alloc > &__x, _StrictWeakOrdering __comp)
Definition bslstp_slist.h:630
const_iterator before_begin() const
Definition bslstp_slist.h:394
iterator previous(const_iterator __pos)
Definition bslstp_slist.h:430
void push_front(const value_type &__x=_Tp())
Definition bslstp_slist.h:418
void splice_after(iterator __pos, iterator __prev)
Definition bslstp_slist.h:554
_Slist_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition bslstp_slist.h:277
void splice(iterator __pos, _Self &__x, iterator __i)
Definition bslstp_slist.h:576
void splice(iterator __pos, _Self &__x)
Definition bslstp_slist.h:569
slist(const _Self &__x, const allocator_type &__a)
Definition bslstp_slist.h:328
void sort()
Definition bslstp_slist.h:888
void insert(iterator __pos, _InIter __first, _InIter __last)
Definition bslstp_slist.h:507
std::forward_iterator_tag _Iterator_category
Definition bslstp_slist.h:275
void _M_assign_dispatch(_InputIter __first, _InputIter __last, bsl::false_type *)
Definition bslstp_slist.h:369
const_iterator begin() const
Definition bslstp_slist.h:398
_Slist_iterator< _Tp, _Const_traits< _Tp > > const_iterator
Definition bslstp_slist.h:278
size_type max_size() const
Definition bslstp_slist.h:406
value_type * pointer
Definition bslstp_slist.h:269
const_iterator previous(const_iterator __pos) const
Definition bslstp_slist.h:433
void resize(size_type new_size, const value_type &__x=_Tp())
Definition bslstp_slist.h:831
void assign(_InputIterator __first, _InputIterator __last)
Definition bslstp_slist.h:357
slist(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Definition bslstp_slist.h:318
friend struct QuickSwap
Definition bslstp_slist.h:250
~slist()
Definition bslstp_slist.h:343
void assign(size_type __n, const _Tp &__val)
Definition bslstp_slist.h:351
const value_type & const_reference
Definition bslstp_slist.h:272
void remove(const _Tp &__val)
Definition bslstp_slist.h:845
void pop_front()
Definition bslstp_slist.h:422
std::size_t size_type
Definition bslstp_slist.h:273
void _M_assign_dispatch(_Integer __n, _Integer __val, bsl::true_type *)
Definition bslstp_slist.h:364
iterator erase_after(iterator __pos)
Definition bslstp_slist.h:516
void clear()
Definition bslstp_slist.h:536
_Container::iterator iter
Definition bslstp_slist.h:956
output_iterator_tag iterator_category
Definition bslstp_slist.h:959
insert_iterator< _Container > & operator++()
Definition bslstp_slist.h:979
void difference_type
Definition bslstp_slist.h:961
_Container * container
Definition bslstp_slist.h:955
bsl::slist< _Tp, _Alloc > _Container
Definition bslstp_slist.h:954
void reference
Definition bslstp_slist.h:963
insert_iterator< _Container > & operator++(int)
Definition bslstp_slist.h:980
_Container container_type
Definition bslstp_slist.h:958
insert_iterator< _Container > & operator=(const typename _Container::value_type &__val)
Definition bslstp_slist.h:974
insert_iterator< _Container > & operator*()
Definition bslstp_slist.h:978
void pointer
Definition bslstp_slist.h:962
insert_iterator(_Container &__x, typename _Container::iterator __i)
Definition bslstp_slist.h:965
void value_type
Definition bslstp_slist.h:960
#define BSLS_CATCH(X)
Definition bsls_exceptionutil.h:372
#define BSLS_TRY
Definition bsls_exceptionutil.h:370
#define BSLS_RETHROW
Definition bsls_exceptionutil.h:378
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:289
Definition bdlb_printmethods.h:283
_Slist_node_base * __slist_make_link(_Slist_node_base *__prev_node, _Slist_node_base *__new_node)
Definition bslstp_slistbase.h:95
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1279
Definition bslstp_exfunctional.h:323
Definition bdldfp_decimal.h:5188
_Rebind_type::other allocator_type
Definition bslstp_alloc.h:98
Definition bslstp_slist.h:208
_Slist_node_base * _M_erase_after(_Slist_node_base *, _Slist_node_base *)
Definition bslstp_slist.h:778
_STLP_alloc_proxy< _Slist_node_base, _Node, _M_node_allocator_type > _M_head
Definition bslstp_slist.h:239
_Slist_node_base * _M_erase_after(_Slist_node_base *__pos)
Definition bslstp_slist.h:222
_Alloc_traits< _Tp, _Alloc >::allocator_type allocator_type
Definition bslstp_slist.h:210
~_Slist_base()
Definition bslstp_slist.h:217
_Slist_node< _Tp > _Node
Definition bslstp_slist.h:211
_Alloc_traits< _Node, _Alloc >::allocator_type _M_node_allocator_type
Definition bslstp_slist.h:220
allocator_type get_allocator() const
Definition bslstp_slist.h:235
_Slist_base(const allocator_type &__a)
Definition bslstp_slist.h:213
Definition bslstp_slist.h:145
std::ptrdiff_t difference_type
Definition bslstp_slist.h:148
bool operator!=(const _Slist_iterator_base &__y) const
Definition bslstp_slist.h:162
_Slist_node_base * _M_node
Definition bslstp_slist.h:151
std::forward_iterator_tag iterator_category
Definition bslstp_slist.h:149
std::size_t size_type
Definition bslstp_slist.h:147
void _M_incr()
Definition bslstp_slist.h:155
_Slist_iterator_base(_Slist_node_base *__x)
Definition bslstp_slist.h:153
bool operator==(const _Slist_iterator_base &__y) const
Definition bslstp_slist.h:159
Definition bslstp_slist.h:170
_Traits::pointer pointer
Definition bslstp_slist.h:172
_Slist_node< value_type > _Node
Definition bslstp_slist.h:182
_Slist_iterator< _Tp, _Const_traits< _Tp > > const_iterator
Definition bslstp_slist.h:179
_Slist_iterator(const iterator &__x)
Definition bslstp_slist.h:186
_Slist_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition bslstp_slist.h:178
ptrdiff_t difference_type
Definition bslstp_slist.h:176
_Tp value_type
Definition bslstp_slist.h:171
std::forward_iterator_tag iterator_category
Definition bslstp_slist.h:174
pointer operator->() const
Definition bslstp_slist.h:190
reference operator*() const
Definition bslstp_slist.h:188
_Self operator++(int)
Definition bslstp_slist.h:197
std::size_t size_type
Definition bslstp_slist.h:175
_Slist_iterator(_Node *__x)
Definition bslstp_slist.h:184
_Slist_iterator< _Tp, _Traits > _Self
Definition bslstp_slist.h:180
_Traits::reference reference
Definition bslstp_slist.h:173
_Slist_iterator()
Definition bslstp_slist.h:185
_Self & operator++()
Definition bslstp_slist.h:192
Definition bslstp_slistbase.h:90
_Slist_node_base * _M_next
Definition bslstp_slistbase.h:91
Definition bslstp_slist.h:141
_Tp _M_data
Definition bslstp_slist.h:142
Definition bslmf_isfundamental.h:329