123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250 |
- #ifndef BOOST_INTRUSIVE_SLIST_HPP
- #define BOOST_INTRUSIVE_SLIST_HPP
- #include <boost/intrusive/detail/config_begin.hpp>
- #include <boost/intrusive/intrusive_fwd.hpp>
- #include <boost/intrusive/detail/assert.hpp>
- #include <boost/intrusive/slist_hook.hpp>
- #include <boost/intrusive/circular_slist_algorithms.hpp>
- #include <boost/intrusive/linear_slist_algorithms.hpp>
- #include <boost/intrusive/pointer_traits.hpp>
- #include <boost/intrusive/link_mode.hpp>
- #include <boost/intrusive/detail/get_value_traits.hpp>
- #include <boost/intrusive/detail/is_stateful_value_traits.hpp>
- #include <boost/intrusive/detail/default_header_holder.hpp>
- #include <boost/intrusive/detail/uncast.hpp>
- #include <boost/intrusive/detail/mpl.hpp>
- #include <boost/intrusive/detail/iterator.hpp>
- #include <boost/intrusive/detail/slist_iterator.hpp>
- #include <boost/intrusive/detail/array_initializer.hpp>
- #include <boost/intrusive/detail/exception_disposer.hpp>
- #include <boost/intrusive/detail/equal_to_value.hpp>
- #include <boost/intrusive/detail/key_nodeptr_comp.hpp>
- #include <boost/intrusive/detail/simple_disposers.hpp>
- #include <boost/intrusive/detail/size_holder.hpp>
- #include <boost/intrusive/detail/algorithm.hpp>
- #include <boost/intrusive/detail/value_functors.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/static_assert.hpp>
- #include <cstddef>
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- namespace boost {
- namespace intrusive {
- template<class HeaderHolder, class NodePtr, bool>
- struct header_holder_plus_last
- {
- HeaderHolder header_holder_;
- NodePtr last_;
- };
- template<class HeaderHolder, class NodePtr>
- struct header_holder_plus_last<HeaderHolder, NodePtr, false>
- {
- HeaderHolder header_holder_;
- };
- struct default_slist_hook_applier
- { template <class T> struct apply{ typedef typename T::default_slist_hook type; }; };
- template<>
- struct is_default_hook_tag<default_slist_hook_applier>
- { static const bool value = true; };
- struct slist_defaults
- {
- typedef default_slist_hook_applier proto_value_traits;
- static const bool constant_time_size = true;
- static const bool linear = false;
- typedef std::size_t size_type;
- static const bool cache_last = false;
- typedef void header_holder_type;
- };
- struct slist_bool_flags
- {
- static const std::size_t linear_pos = 1u;
- static const std::size_t constant_time_size_pos = 2u;
- static const std::size_t cache_last_pos = 4u;
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- template<class T, class ...Options>
- #else
- template<class ValueTraits, class SizeType, std::size_t BoolFlags, typename HeaderHolder>
- #endif
- class slist_impl
- {
-
- public:
- typedef ValueTraits value_traits;
- typedef typename value_traits::pointer pointer;
- typedef typename value_traits::const_pointer const_pointer;
- typedef typename pointer_traits<pointer>::element_type value_type;
- typedef typename pointer_traits<pointer>::reference reference;
- typedef typename pointer_traits<const_pointer>::reference const_reference;
- typedef typename pointer_traits<pointer>::difference_type difference_type;
- typedef SizeType size_type;
- typedef slist_iterator<value_traits, false> iterator;
- typedef slist_iterator<value_traits, true> const_iterator;
- typedef typename value_traits::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename node_traits::const_node_ptr const_node_ptr;
- typedef typename detail::get_header_holder_type
- < value_traits, HeaderHolder >::type header_holder_type;
- static const bool constant_time_size = 0 != (BoolFlags & slist_bool_flags::constant_time_size_pos);
- static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
- static const bool linear = 0 != (BoolFlags & slist_bool_flags::linear_pos);
- static const bool cache_last = 0 != (BoolFlags & slist_bool_flags::cache_last_pos);
- static const bool has_container_from_iterator =
- detail::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value;
- typedef typename detail::if_c
- < linear
- , linear_slist_algorithms<node_traits>
- , circular_slist_algorithms<node_traits>
- >::type node_algorithms;
-
- private:
- typedef detail::size_holder<constant_time_size, size_type> size_traits;
-
- BOOST_MOVABLE_BUT_NOT_COPYABLE(slist_impl)
- static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
-
- BOOST_STATIC_ASSERT(!(constant_time_size && ((int)value_traits::link_mode == (int)auto_unlink)));
-
- BOOST_STATIC_ASSERT(!(linear && ((int)value_traits::link_mode == (int)auto_unlink)));
-
- BOOST_STATIC_ASSERT(!(cache_last && ((int)value_traits::link_mode == (int)auto_unlink)));
- node_ptr get_end_node()
- { return node_ptr(linear ? node_ptr() : this->get_root_node()); }
- const_node_ptr get_end_node() const
- {
- return const_node_ptr
- (linear ? const_node_ptr() : this->get_root_node()); }
- node_ptr get_root_node()
- { return data_.root_plus_size_.header_holder_.get_node(); }
- const_node_ptr get_root_node() const
- { return data_.root_plus_size_.header_holder_.get_node(); }
- node_ptr get_last_node()
- { return this->get_last_node(detail::bool_<cache_last>()); }
- const_node_ptr get_last_node() const
- { return this->get_last_node(detail::bool_<cache_last>()); }
- void set_last_node(const node_ptr &n)
- { return this->set_last_node(n, detail::bool_<cache_last>()); }
- static node_ptr get_last_node(detail::bool_<false>)
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- return node_ptr();
- }
- static void set_last_node(const node_ptr &, detail::bool_<false>)
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- }
- node_ptr get_last_node(detail::bool_<true>)
- { return node_ptr(data_.root_plus_size_.last_); }
- const_node_ptr get_last_node(detail::bool_<true>) const
- { return const_node_ptr(data_.root_plus_size_.last_); }
- void set_last_node(const node_ptr & n, detail::bool_<true>)
- { data_.root_plus_size_.last_ = n; }
- void set_default_constructed_state()
- {
- node_algorithms::init_header(this->get_root_node());
- this->priv_size_traits().set_size(size_type(0));
- if(cache_last){
- this->set_last_node(this->get_root_node());
- }
- }
- typedef header_holder_plus_last<header_holder_type, node_ptr, cache_last> header_holder_plus_last_t;
- struct root_plus_size
- : public size_traits
- , public header_holder_plus_last_t
- {};
- struct data_t
- : public value_traits
- {
- typedef typename slist_impl::value_traits value_traits;
- explicit data_t(const value_traits &val_traits)
- : value_traits(val_traits)
- {}
- root_plus_size root_plus_size_;
- } data_;
- size_traits &priv_size_traits()
- { return data_.root_plus_size_; }
- const size_traits &priv_size_traits() const
- { return data_.root_plus_size_; }
- const value_traits &priv_value_traits() const
- { return data_; }
- value_traits &priv_value_traits()
- { return data_; }
- typedef typename boost::intrusive::value_traits_pointers
- <ValueTraits>::const_value_traits_ptr const_value_traits_ptr;
- const_value_traits_ptr priv_value_traits_ptr() const
- { return pointer_traits<const_value_traits_ptr>::pointer_to(this->priv_value_traits()); }
-
- public:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- slist_impl( const node_ptr & f, const node_ptr & before_l
- , size_type n, const value_traits &v_traits = value_traits())
- : data_(v_traits)
- {
- if(n){
- this->priv_size_traits().set_size(n);
- if(cache_last){
- this->set_last_node(before_l);
- }
- node_traits::set_next(this->get_root_node(), f);
- node_traits::set_next(before_l, this->get_end_node());
- }
- else{
- this->set_default_constructed_state();
- }
- }
-
-
-
-
-
-
-
- slist_impl()
- : data_(value_traits())
- { this->set_default_constructed_state(); }
-
-
-
-
-
-
- explicit slist_impl(const value_traits &v_traits)
- : data_(v_traits)
- { this->set_default_constructed_state(); }
-
-
-
-
-
-
-
-
- template<class Iterator>
- slist_impl(Iterator b, Iterator e, const value_traits &v_traits = value_traits())
- : data_(v_traits)
- {
- this->set_default_constructed_state();
-
- this->insert_after(this->cbefore_begin(), b, e);
- }
-
-
-
-
-
-
-
-
-
- slist_impl(BOOST_RV_REF(slist_impl) x)
- : data_(::boost::move(x.priv_value_traits()))
- {
- this->set_default_constructed_state();
-
- this->swap(x);
- }
-
-
- slist_impl& operator=(BOOST_RV_REF(slist_impl) x)
- { this->swap(x); return *this; }
-
-
-
-
-
-
-
-
-
- ~slist_impl()
- {
- if(is_safe_autounlink<ValueTraits::link_mode>::value){
- this->clear();
- node_algorithms::init(this->get_root_node());
- }
- }
-
-
-
-
-
-
-
-
- void clear()
- {
- if(safemode_or_autounlink){
- this->clear_and_dispose(detail::null_disposer());
- }
- else{
- this->set_default_constructed_state();
- }
- }
-
-
-
-
-
-
-
-
-
-
- template <class Disposer>
- void clear_and_dispose(Disposer disposer)
- {
- const_iterator it(this->begin()), itend(this->end());
- while(it != itend){
- node_ptr to_erase(it.pointed_node());
- ++it;
- if(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(priv_value_traits().to_value_ptr(to_erase));
- }
- this->set_default_constructed_state();
- }
-
-
-
-
-
-
-
-
-
-
- void push_front(reference value)
- {
- node_ptr to_insert = priv_value_traits().to_node_ptr(value);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::inited(to_insert));
- if(cache_last){
- if(this->empty()){
- this->set_last_node(to_insert);
- }
- }
- node_algorithms::link_after(this->get_root_node(), to_insert);
- this->priv_size_traits().increment();
- }
-
-
-
-
-
-
-
-
-
-
-
- void push_back(reference value)
- {
- BOOST_STATIC_ASSERT((cache_last));
- node_ptr n = priv_value_traits().to_node_ptr(value);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::inited(n));
- node_algorithms::link_after(this->get_last_node(), n);
- if(cache_last){
- this->set_last_node(n);
- }
- this->priv_size_traits().increment();
- }
-
-
-
-
-
-
-
-
- void pop_front()
- { return this->pop_front_and_dispose(detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- void pop_front_and_dispose(Disposer disposer)
- {
- node_ptr to_erase = node_traits::get_next(this->get_root_node());
- node_algorithms::unlink_after(this->get_root_node());
- this->priv_size_traits().decrement();
- if(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(priv_value_traits().to_value_ptr(to_erase));
- if(cache_last){
- if(this->empty()){
- this->set_last_node(this->get_root_node());
- }
- }
- }
-
-
-
-
-
- reference front()
- { return *this->priv_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); }
-
-
-
-
-
- const_reference front() const
- { return *this->priv_value_traits().to_value_ptr(detail::uncast(node_traits::get_next(this->get_root_node()))); }
-
-
-
-
-
-
-
-
- reference back()
- {
- BOOST_STATIC_ASSERT((cache_last));
- return *this->priv_value_traits().to_value_ptr(this->get_last_node());
- }
-
-
-
-
-
-
-
-
- const_reference back() const
- {
- BOOST_STATIC_ASSERT((cache_last));
- return *this->priv_value_traits().to_value_ptr(this->get_last_node());
- }
-
-
-
-
-
- iterator begin()
- { return iterator (node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- const_iterator begin() const
- { return const_iterator (node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- const_iterator cbegin() const
- { return const_iterator(node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- iterator end()
- { return iterator(this->get_end_node(), this->priv_value_traits_ptr()); }
-
-
-
-
-
- const_iterator end() const
- { return const_iterator(detail::uncast(this->get_end_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- const_iterator cend() const
- { return this->end(); }
-
-
-
-
-
-
- iterator before_begin()
- { return iterator(this->get_root_node(), this->priv_value_traits_ptr()); }
-
-
-
-
-
-
- const_iterator before_begin() const
- { return const_iterator(detail::uncast(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
-
- const_iterator cbefore_begin() const
- { return this->before_begin(); }
-
-
-
-
-
-
-
- iterator last()
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- return iterator (this->get_last_node(), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
- const_iterator last() const
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- return const_iterator (this->get_last_node(), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
- const_iterator clast() const
- { return const_iterator(this->get_last_node(), this->priv_value_traits_ptr()); }
-
-
-
-
-
-
-
-
- static slist_impl &container_from_end_iterator(iterator end_iterator)
- { return slist_impl::priv_container_from_end_iterator(end_iterator); }
-
-
-
-
-
-
-
-
- static const slist_impl &container_from_end_iterator(const_iterator end_iterator)
- { return slist_impl::priv_container_from_end_iterator(end_iterator); }
-
-
-
-
-
-
-
-
- size_type size() const
- {
- if(constant_time_size)
- return this->priv_size_traits().get_size();
- else
- return node_algorithms::count(this->get_root_node()) - 1;
- }
-
-
-
-
-
-
-
- bool empty() const
- { return node_algorithms::unique(this->get_root_node()); }
-
-
-
-
-
-
-
-
- void swap(slist_impl& other)
- {
- if(cache_last){
- priv_swap_cache_last(this, &other);
- }
- else{
- this->priv_swap_lists(this->get_root_node(), other.get_root_node(), detail::bool_<linear>());
- }
- this->priv_size_traits().swap(other.priv_size_traits());
- }
-
-
-
-
-
-
-
-
-
- void shift_backwards(size_type n = 1)
- { this->priv_shift_backwards(n, detail::bool_<linear>()); }
-
-
-
-
-
-
-
-
-
- void shift_forward(size_type n = 1)
- { this->priv_shift_forward(n, detail::bool_<linear>()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class Cloner, class Disposer>
- void clone_from(const slist_impl &src, Cloner cloner, Disposer disposer)
- {
- this->clear_and_dispose(disposer);
- detail::exception_disposer<slist_impl, Disposer>
- rollback(*this, disposer);
- const_iterator prev(this->cbefore_begin());
- const_iterator b(src.begin()), e(src.end());
- for(; b != e; ++b){
- prev = this->insert_after(prev, *cloner(*b));
- }
- rollback.release();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class Cloner, class Disposer>
- void clone_from(BOOST_RV_REF(slist_impl) src, Cloner cloner, Disposer disposer)
- {
- this->clear_and_dispose(disposer);
- detail::exception_disposer<slist_impl, Disposer>
- rollback(*this, disposer);
- iterator prev(this->cbefore_begin());
- iterator b(src.begin()), e(src.end());
- for(; b != e; ++b){
- prev = this->insert_after(prev, *cloner(*b));
- }
- rollback.release();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert_after(const_iterator prev_p, reference value)
- {
- node_ptr n = priv_value_traits().to_node_ptr(value);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::inited(n));
- node_ptr prev_n(prev_p.pointed_node());
- node_algorithms::link_after(prev_n, n);
- if(cache_last && (this->get_last_node() == prev_n)){
- this->set_last_node(n);
- }
- this->priv_size_traits().increment();
- return iterator (n, this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- void insert_after(const_iterator prev_p, Iterator f, Iterator l)
- {
-
- size_type count = 0;
- node_ptr prev_n(prev_p.pointed_node());
- for (; f != l; ++f, ++count){
- const node_ptr n = priv_value_traits().to_node_ptr(*f);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::inited(n));
- node_algorithms::link_after(prev_n, n);
- prev_n = n;
- }
-
- if(cache_last && (this->get_last_node() == prev_p.pointed_node())){
- this->set_last_node(prev_n);
- }
- if(constant_time_size){
- this->priv_size_traits().increase(count);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, reference value)
- { return this->insert_after(this->previous(p), value); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- void insert(const_iterator p, Iterator b, Iterator e)
- { return this->insert_after(this->previous(p), b, e); }
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase_after(const_iterator prev)
- { return this->erase_after_and_dispose(prev, detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase_after(const_iterator before_f, const_iterator l)
- {
- if(safemode_or_autounlink || constant_time_size){
- return this->erase_after_and_dispose(before_f, l, detail::null_disposer());
- }
- else{
- const node_ptr bfp = before_f.pointed_node();
- const node_ptr lp = l.pointed_node();
- if(cache_last){
- if(lp == this->get_end_node()){
- this->set_last_node(bfp);
- }
- }
- node_algorithms::unlink_after(bfp, lp);
- return l.unconst();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase_after(const_iterator before_f, const_iterator l, size_type n)
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance((++const_iterator(before_f)).pointed_node(), l.pointed_node()) == n);
- if(safemode_or_autounlink){
- return this->erase_after(before_f, l);
- }
- else{
- const node_ptr bfp = before_f.pointed_node();
- const node_ptr lp = l.pointed_node();
- if(cache_last){
- if((lp == this->get_end_node())){
- this->set_last_node(bfp);
- }
- }
- node_algorithms::unlink_after(bfp, lp);
- if(constant_time_size){
- this->priv_size_traits().decrease(n);
- }
- return l.unconst();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator i)
- { return this->erase_after(this->previous(i)); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator f, const_iterator l)
- { return this->erase_after(this->previous(f), l); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator f, const_iterator l, size_type n)
- { return this->erase_after(this->previous(f), l, n); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_after_and_dispose(const_iterator prev, Disposer disposer)
- {
- const_iterator it(prev);
- ++it;
- node_ptr to_erase(it.pointed_node());
- ++it;
- node_ptr prev_n(prev.pointed_node());
- node_algorithms::unlink_after(prev_n);
- if(cache_last && (to_erase == this->get_last_node())){
- this->set_last_node(prev_n);
- }
- if(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(priv_value_traits().to_value_ptr(to_erase));
- this->priv_size_traits().decrement();
- return it.unconst();
- }
-
- static iterator s_insert_after(const_iterator const prev_p, reference value)
- {
- BOOST_STATIC_ASSERT(((!cache_last)&&(!constant_time_size)&&(!stateful_value_traits)));
- node_ptr const n = value_traits::to_node_ptr(value);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::inited(n));
- node_algorithms::link_after(prev_p.pointed_node(), n);
- return iterator (n, const_value_traits_ptr());
- }
- template<class Disposer>
- static iterator s_erase_after_and_dispose(const_iterator prev, Disposer disposer)
- {
- BOOST_STATIC_ASSERT(((!cache_last)&&(!constant_time_size)&&(!stateful_value_traits)));
- const_iterator it(prev);
- ++it;
- node_ptr to_erase(it.pointed_node());
- ++it;
- node_ptr prev_n(prev.pointed_node());
- node_algorithms::unlink_after(prev_n);
- if(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(value_traits::to_value_ptr(to_erase));
- return it.unconst();
- }
- template<class Disposer>
- static iterator s_erase_after_and_dispose(const_iterator before_f, const_iterator l, Disposer disposer)
- {
- BOOST_STATIC_ASSERT(((!cache_last)&&(!constant_time_size)&&(!stateful_value_traits)));
- node_ptr bfp(before_f.pointed_node()), lp(l.pointed_node());
- node_ptr fp(node_traits::get_next(bfp));
- node_algorithms::unlink_after(bfp, lp);
- while(fp != lp){
- node_ptr to_erase(fp);
- fp = node_traits::get_next(fp);
- if(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(value_traits::to_value_ptr(to_erase));
- }
- return l.unconst();
- }
- static iterator s_erase_after(const_iterator prev)
- { return s_erase_after_and_dispose(prev, detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_after_and_dispose(const_iterator before_f, const_iterator l, Disposer disposer)
- {
- node_ptr bfp(before_f.pointed_node()), lp(l.pointed_node());
- node_ptr fp(node_traits::get_next(bfp));
- node_algorithms::unlink_after(bfp, lp);
- while(fp != lp){
- node_ptr to_erase(fp);
- fp = node_traits::get_next(fp);
- if(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(priv_value_traits().to_value_ptr(to_erase));
- this->priv_size_traits().decrement();
- }
- if(cache_last && (node_traits::get_next(bfp) == this->get_end_node())){
- this->set_last_node(bfp);
- }
- return l.unconst();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_and_dispose(const_iterator i, Disposer disposer)
- { return this->erase_after_and_dispose(this->previous(i), disposer); }
- #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- template<class Disposer>
- iterator erase_and_dispose(iterator i, Disposer disposer)
- { return this->erase_and_dispose(const_iterator(i), disposer); }
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_and_dispose(const_iterator f, const_iterator l, Disposer disposer)
- { return this->erase_after_and_dispose(this->previous(f), l, disposer); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- void assign(Iterator b, Iterator e)
- {
- this->clear();
- this->insert_after(this->cbefore_begin(), b, e);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator, class Disposer>
- void dispose_and_assign(Disposer disposer, Iterator b, Iterator e)
- {
- this->clear_and_dispose(disposer);
- this->insert_after(this->cbefore_begin(), b, e, disposer);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice_after(const_iterator prev, slist_impl &x, const_iterator *l = 0)
- {
- if(x.empty()){
- if(l) *l = prev;
- }
- else if(linear && this->empty()){
- this->swap(x);
- if(l) *l = this->previous(this->cend());
- }
- else{
- const_iterator last_x(x.previous(x.end()));
- node_ptr prev_n(prev.pointed_node());
- node_ptr last_x_n(last_x.pointed_node());
- if(cache_last){
- x.set_last_node(x.get_root_node());
- if(node_traits::get_next(prev_n) == this->get_end_node()){
- this->set_last_node(last_x_n);
- }
- }
- node_algorithms::transfer_after( prev_n, x.before_begin().pointed_node(), last_x_n);
- this->priv_size_traits().increase(x.priv_size_traits().get_size());
- x.priv_size_traits().set_size(size_type(0));
- if(l) *l = last_x;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator prev_ele)
- {
- const_iterator elem = prev_ele;
- this->splice_after(prev_pos, x, prev_ele, ++elem, 1);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l)
- {
- if(constant_time_size)
- this->splice_after(prev_pos, x, before_f, before_l, node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node()));
- else
- this->priv_splice_after
- (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l, size_type n)
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node()) == n);
- this->priv_splice_after
- (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node());
- if(constant_time_size){
- this->priv_size_traits().increase(n);
- x.priv_size_traits().decrease(n);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator it, slist_impl &x, const_iterator *l = 0)
- { this->splice_after(this->previous(it), x, l); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator pos, slist_impl &x, const_iterator elem)
- { return this->splice_after(this->previous(pos), x, x.previous(elem)); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator pos, slist_impl &x, const_iterator f, const_iterator l)
- { return this->splice_after(this->previous(pos), x, x.previous(f), x.previous(l)); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator pos, slist_impl &x, const_iterator f, const_iterator l, size_type n)
- { return this->splice_after(this->previous(pos), x, x.previous(f), x.previous(l), n); }
-
-
-
-
-
-
-
-
-
-
-
- template<class Predicate>
- void sort(Predicate p)
- {
- if (node_traits::get_next(node_traits::get_next(this->get_root_node()))
- != this->get_root_node()) {
- slist_impl carry(this->priv_value_traits());
- detail::array_initializer<slist_impl, 64> counter(this->priv_value_traits());
- int fill = 0;
- const_iterator last_inserted;
- while(!this->empty()){
- last_inserted = this->cbegin();
- carry.splice_after(carry.cbefore_begin(), *this, this->cbefore_begin());
- int i = 0;
- while(i < fill && !counter[i].empty()) {
- carry.swap(counter[i]);
- carry.merge(counter[i++], p, &last_inserted);
- }
- BOOST_INTRUSIVE_INVARIANT_ASSERT(counter[i].empty());
- const_iterator last_element(carry.previous(last_inserted, carry.end()));
- if(constant_time_size){
- counter[i].splice_after( counter[i].cbefore_begin(), carry
- , carry.cbefore_begin(), last_element
- , carry.size());
- }
- else{
- counter[i].splice_after( counter[i].cbefore_begin(), carry
- , carry.cbefore_begin(), last_element);
- }
- if(i == fill)
- ++fill;
- }
- for (int i = 1; i < fill; ++i)
- counter[i].merge(counter[i-1], p, &last_inserted);
- --fill;
- const_iterator last_element(counter[fill].previous(last_inserted, counter[fill].end()));
- if(constant_time_size){
- this->splice_after( cbefore_begin(), counter[fill], counter[fill].cbefore_begin()
- , last_element, counter[fill].size());
- }
- else{
- this->splice_after( cbefore_begin(), counter[fill], counter[fill].cbefore_begin()
- , last_element);
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void sort()
- { this->sort(value_less<value_type>()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Predicate>
- void merge(slist_impl& x, Predicate p, const_iterator *l = 0)
- {
- const_iterator e(this->cend()), ex(x.cend()), bb(this->cbefore_begin()),
- bb_next;
- if(l) *l = e.unconst();
- while(!x.empty()){
- const_iterator ibx_next(x.cbefore_begin()), ibx(ibx_next++);
- while (++(bb_next = bb) != e && !p(*ibx_next, *bb_next)){
- bb = bb_next;
- }
- if(bb_next == e){
-
- this->splice_after(bb, x, l);
- break;
- }
- else{
- size_type n(0);
- do{
- ibx = ibx_next; ++n;
- } while(++(ibx_next = ibx) != ex && p(*ibx_next, *bb_next));
- this->splice_after(bb, x, x.before_begin(), ibx, n);
- if(l) *l = ibx;
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
- void merge(slist_impl& x)
- { this->merge(x, value_less<value_type>()); }
-
-
-
-
-
-
-
- void reverse()
- {
- if(cache_last && !this->empty()){
- this->set_last_node(node_traits::get_next(this->get_root_node()));
- }
- this->priv_reverse(detail::bool_<linear>());
- }
-
-
-
-
-
-
-
-
-
-
- void remove(const_reference value)
- { this->remove_if(detail::equal_to_value<const_reference>(value)); }
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- void remove_and_dispose(const_reference value, Disposer disposer)
- { this->remove_and_dispose_if(detail::equal_to_value<const_reference>(value), disposer); }
-
-
-
-
-
-
-
-
-
- template<class Pred>
- void remove_if(Pred pred)
- {
- const node_ptr bbeg = this->get_root_node();
- typename node_algorithms::stable_partition_info info;
- node_algorithms::stable_partition
- (bbeg, this->get_end_node(), detail::key_nodeptr_comp<Pred, value_traits>(pred, &this->priv_value_traits()), info);
-
- if(cache_last){
- this->set_last_node(info.new_last_node);
- }
-
- this->erase_after( const_iterator(bbeg, this->priv_value_traits_ptr())
- , const_iterator(info.beg_2st_partition, this->priv_value_traits_ptr())
- , info.num_1st_partition);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Pred, class Disposer>
- void remove_and_dispose_if(Pred pred, Disposer disposer)
- {
- const node_ptr bbeg = this->get_root_node();
- typename node_algorithms::stable_partition_info info;
- node_algorithms::stable_partition
- (bbeg, this->get_end_node(), detail::key_nodeptr_comp<Pred, value_traits>(pred, &this->priv_value_traits()), info);
-
- if(cache_last){
- this->set_last_node(info.new_last_node);
- }
-
- this->erase_after_and_dispose( const_iterator(bbeg, this->priv_value_traits_ptr())
- , const_iterator(info.beg_2st_partition, this->priv_value_traits_ptr())
- , disposer);
- }
-
-
-
-
-
-
-
-
-
- void unique()
- { this->unique_and_dispose(value_equal<value_type>(), detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
- template<class BinaryPredicate>
- void unique(BinaryPredicate pred)
- { this->unique_and_dispose(pred, detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- void unique_and_dispose(Disposer disposer)
- { this->unique(value_equal<value_type>(), disposer); }
-
-
-
-
-
-
-
-
-
-
-
-
- template<class BinaryPredicate, class Disposer>
- void unique_and_dispose(BinaryPredicate pred, Disposer disposer)
- {
- const_iterator end_n(this->cend());
- const_iterator bcur(this->cbegin());
- if(bcur != end_n){
- const_iterator cur(bcur);
- ++cur;
- while(cur != end_n) {
- if (pred(*bcur, *cur)){
- cur = this->erase_after_and_dispose(bcur, disposer);
- }
- else{
- bcur = cur;
- ++cur;
- }
- }
- if(cache_last){
- this->set_last_node(bcur.pointed_node());
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
- static iterator s_iterator_to(reference value)
- {
- BOOST_STATIC_ASSERT((!stateful_value_traits));
- return iterator (value_traits::to_node_ptr(value), const_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
-
-
- static const_iterator s_iterator_to(const_reference value)
- {
- BOOST_STATIC_ASSERT((!stateful_value_traits));
- reference r =*detail::uncast(pointer_traits<const_pointer>::pointer_to(value));
- return const_iterator(value_traits::to_node_ptr(r), const_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
- iterator iterator_to(reference value)
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(linear || !node_algorithms::inited(this->priv_value_traits().to_node_ptr(value)));
- return iterator (this->priv_value_traits().to_node_ptr(value), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
- const_iterator iterator_to(const_reference value) const
- {
- reference r =*detail::uncast(pointer_traits<const_pointer>::pointer_to(value));
- BOOST_INTRUSIVE_INVARIANT_ASSERT (linear || !node_algorithms::inited(this->priv_value_traits().to_node_ptr(r)));
- return const_iterator(this->priv_value_traits().to_node_ptr(r), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
- iterator previous(iterator i)
- { return this->previous(this->cbefore_begin(), i); }
-
-
-
-
-
-
-
-
- const_iterator previous(const_iterator i) const
- { return this->previous(this->cbefore_begin(), i); }
-
-
-
-
-
-
-
-
-
- iterator previous(const_iterator prev_from, iterator i)
- { return this->previous(prev_from, const_iterator(i)).unconst(); }
-
-
-
-
-
-
-
-
-
- const_iterator previous(const_iterator prev_from, const_iterator i) const
- {
- if(cache_last && (i.pointed_node() == this->get_end_node())){
- return const_iterator(detail::uncast(this->get_last_node()), this->priv_value_traits_ptr());
- }
- return const_iterator
- (node_algorithms::get_previous_node
- (prev_from.pointed_node(), i.pointed_node()), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l)
- {
- if(constant_time_size)
- this->incorporate_after(prev_pos, f, before_l, node_algorithms::distance(f.pointed_node(), before_l.pointed_node())+1);
- else
- this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l, size_type n)
- {
- if(n){
- BOOST_INTRUSIVE_INVARIANT_ASSERT(n > 0);
- BOOST_INTRUSIVE_INVARIANT_ASSERT
- (size_type(boost::intrusive::iterator_distance
- ( iterator(f, this->priv_value_traits_ptr())
- , iterator(before_l, this->priv_value_traits_ptr())))
- +1 == n);
- this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l);
- if(constant_time_size){
- this->priv_size_traits().increase(n);
- }
- }
- }
-
-
-
-
-
-
-
- void check() const
- {
- const_node_ptr header_ptr = get_root_node();
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(node_traits::get_next(header_ptr));
- if (node_traits::get_next(header_ptr) == header_ptr)
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(!constant_time_size || this->priv_size_traits().get_size() == 0);
- return;
- }
- size_t node_count = 0;
- const_node_ptr p = header_ptr;
- while (true)
- {
- const_node_ptr next_p = node_traits::get_next(p);
- if (!linear)
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(next_p);
- }
- else
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(next_p != header_ptr);
- }
- if ((!linear && next_p == header_ptr) || (linear && !next_p))
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(!cache_last || get_last_node() == p);
- break;
- }
- p = next_p;
- ++node_count;
- }
- BOOST_INTRUSIVE_INVARIANT_ASSERT(!constant_time_size || this->priv_size_traits().get_size() == node_count);
- }
- friend bool operator==(const slist_impl &x, const slist_impl &y)
- {
- if(constant_time_size && x.size() != y.size()){
- return false;
- }
- return ::boost::intrusive::algo_equal(x.cbegin(), x.cend(), y.cbegin(), y.cend());
- }
- friend bool operator!=(const slist_impl &x, const slist_impl &y)
- { return !(x == y); }
- friend bool operator<(const slist_impl &x, const slist_impl &y)
- { return ::boost::intrusive::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
- friend bool operator>(const slist_impl &x, const slist_impl &y)
- { return y < x; }
- friend bool operator<=(const slist_impl &x, const slist_impl &y)
- { return !(y < x); }
- friend bool operator>=(const slist_impl &x, const slist_impl &y)
- { return !(x < y); }
- friend void swap(slist_impl &x, slist_impl &y)
- { x.swap(y); }
- private:
- void priv_splice_after(node_ptr prev_pos_n, slist_impl &x, node_ptr before_f_n, node_ptr before_l_n)
- {
- if (cache_last && (before_f_n != before_l_n)){
- if(prev_pos_n == this->get_last_node()){
- this->set_last_node(before_l_n);
- }
- if(&x != this && node_traits::get_next(before_l_n) == x.get_end_node()){
- x.set_last_node(before_f_n);
- }
- }
- node_algorithms::transfer_after(prev_pos_n, before_f_n, before_l_n);
- }
- void priv_incorporate_after(node_ptr prev_pos_n, node_ptr first_n, node_ptr before_l_n)
- {
- if(cache_last){
- if(prev_pos_n == this->get_last_node()){
- this->set_last_node(before_l_n);
- }
- }
- node_algorithms::incorporate_after(prev_pos_n, first_n, before_l_n);
- }
- void priv_reverse(detail::bool_<false>)
- { node_algorithms::reverse(this->get_root_node()); }
- void priv_reverse(detail::bool_<true>)
- {
- node_ptr new_first = node_algorithms::reverse
- (node_traits::get_next(this->get_root_node()));
- node_traits::set_next(this->get_root_node(), new_first);
- }
- void priv_shift_backwards(size_type n, detail::bool_<false>)
- {
- node_ptr l = node_algorithms::move_forward(this->get_root_node(), (std::size_t)n);
- if(cache_last && l){
- this->set_last_node(l);
- }
- }
- void priv_shift_backwards(size_type n, detail::bool_<true>)
- {
- typename node_algorithms::node_pair ret(
- node_algorithms::move_first_n_forward
- (node_traits::get_next(this->get_root_node()), (std::size_t)n));
- if(ret.first){
- node_traits::set_next(this->get_root_node(), ret.first);
- if(cache_last){
- this->set_last_node(ret.second);
- }
- }
- }
- void priv_shift_forward(size_type n, detail::bool_<false>)
- {
- node_ptr l = node_algorithms::move_backwards(this->get_root_node(), (std::size_t)n);
- if(cache_last && l){
- this->set_last_node(l);
- }
- }
- void priv_shift_forward(size_type n, detail::bool_<true>)
- {
- typename node_algorithms::node_pair ret(
- node_algorithms::move_first_n_backwards
- (node_traits::get_next(this->get_root_node()), (std::size_t)n));
- if(ret.first){
- node_traits::set_next(this->get_root_node(), ret.first);
- if(cache_last){
- this->set_last_node(ret.second);
- }
- }
- }
- static void priv_swap_cache_last(slist_impl *this_impl, slist_impl *other_impl)
- {
- bool other_was_empty = false;
- if(this_impl->empty()){
-
- if(other_impl->empty())
- return;
-
- slist_impl *tmp = this_impl;
- this_impl = other_impl;
- other_impl = tmp;
- other_was_empty = true;
- }
- else{
- other_was_empty = other_impl->empty();
- }
-
- node_ptr other_old_last(other_impl->get_last_node());
- node_ptr other_bfirst(other_impl->get_root_node());
- node_ptr this_bfirst(this_impl->get_root_node());
- node_ptr this_old_last(this_impl->get_last_node());
-
- node_algorithms::transfer_after(other_bfirst, this_bfirst, this_old_last);
- other_impl->set_last_node(this_old_last);
- if(other_was_empty){
- this_impl->set_last_node(this_bfirst);
- }
- else{
-
- node_algorithms::transfer_after(this_bfirst, this_old_last, other_old_last);
- this_impl->set_last_node(other_old_last);
- }
- }
-
- static void priv_swap_lists(node_ptr this_node, node_ptr other_node, detail::bool_<false>)
- { node_algorithms::swap_nodes(this_node, other_node); }
-
- static void priv_swap_lists(node_ptr this_node, node_ptr other_node, detail::bool_<true>)
- { node_algorithms::swap_trailing_nodes(this_node, other_node); }
- static slist_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
- {
-
-
- BOOST_STATIC_ASSERT(!linear);
- BOOST_STATIC_ASSERT((has_container_from_iterator));
- node_ptr p = end_iterator.pointed_node();
- header_holder_type* h = header_holder_type::get_holder(p);
- header_holder_plus_last_t* hpl = detail::parent_from_member< header_holder_plus_last_t, header_holder_type>
- (h, &header_holder_plus_last_t::header_holder_);
- root_plus_size* r = static_cast< root_plus_size* >(hpl);
- data_t *d = detail::parent_from_member<data_t, root_plus_size>
- ( r, &data_t::root_plus_size_);
- slist_impl *s = detail::parent_from_member<slist_impl, data_t>(d, &slist_impl::data_);
- return *s;
- }
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- template<class T, class ...Options>
- #else
- template<class T, class O1 = void, class O2 = void, class O3 = void, class O4 = void, class O5 = void, class O6 = void>
- #endif
- struct make_slist
- {
-
- typedef typename pack_options
- < slist_defaults,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6
- #else
- Options...
- #endif
- >::type packed_options;
- typedef typename detail::get_value_traits
- <T, typename packed_options::proto_value_traits>::type value_traits;
- typedef slist_impl
- < value_traits
- , typename packed_options::size_type
- , (std::size_t(packed_options::linear)*slist_bool_flags::linear_pos)
- |(std::size_t(packed_options::constant_time_size)*slist_bool_flags::constant_time_size_pos)
- |(std::size_t(packed_options::cache_last)*slist_bool_flags::cache_last_pos)
- , typename packed_options::header_holder_type
- > implementation_defined;
-
- typedef implementation_defined type;
- };
- #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
- #else
- template<class T, class ...Options>
- #endif
- class slist
- : public make_slist<T,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6
- #else
- Options...
- #endif
- >::type
- {
- typedef typename make_slist
- <T,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6
- #else
- Options...
- #endif
- >::type Base;
-
- BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value));
- BOOST_MOVABLE_BUT_NOT_COPYABLE(slist)
- public:
- typedef typename Base::value_traits value_traits;
- typedef typename Base::iterator iterator;
- typedef typename Base::const_iterator const_iterator;
- typedef typename Base::size_type size_type;
- typedef typename Base::node_ptr node_ptr;
- BOOST_INTRUSIVE_FORCEINLINE slist()
- : Base()
- {}
- BOOST_INTRUSIVE_FORCEINLINE explicit slist(const value_traits &v_traits)
- : Base(v_traits)
- {}
- struct incorporate_t{};
- BOOST_INTRUSIVE_FORCEINLINE slist( const node_ptr & f, const node_ptr & before_l
- , size_type n, const value_traits &v_traits = value_traits())
- : Base(f, before_l, n, v_traits)
- {}
- template<class Iterator>
- BOOST_INTRUSIVE_FORCEINLINE slist(Iterator b, Iterator e, const value_traits &v_traits = value_traits())
- : Base(b, e, v_traits)
- {}
- BOOST_INTRUSIVE_FORCEINLINE slist(BOOST_RV_REF(slist) x)
- : Base(BOOST_MOVE_BASE(Base, x))
- {}
- BOOST_INTRUSIVE_FORCEINLINE slist& operator=(BOOST_RV_REF(slist) x)
- { return static_cast<slist &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
- template <class Cloner, class Disposer>
- BOOST_INTRUSIVE_FORCEINLINE void clone_from(const slist &src, Cloner cloner, Disposer disposer)
- { Base::clone_from(src, cloner, disposer); }
- template <class Cloner, class Disposer>
- BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(slist) src, Cloner cloner, Disposer disposer)
- { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
- BOOST_INTRUSIVE_FORCEINLINE static slist &container_from_end_iterator(iterator end_iterator)
- { return static_cast<slist &>(Base::container_from_end_iterator(end_iterator)); }
- BOOST_INTRUSIVE_FORCEINLINE static const slist &container_from_end_iterator(const_iterator end_iterator)
- { return static_cast<const slist &>(Base::container_from_end_iterator(end_iterator)); }
- };
- #endif
- }
- }
- #include <boost/intrusive/detail/config_end.hpp>
- #endif
|