12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246 |
- #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/intrusive/detail/node_cloner_disposer.hpp>
- #include <boost/move/utility_core.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_INTRUSIVE_STATIC_ASSERT(!(constant_time_size && ((int)value_traits::link_mode == (int)auto_unlink)));
-
- BOOST_INTRUSIVE_STATIC_ASSERT(!(linear && ((int)value_traits::link_mode == (int)auto_unlink)));
-
- BOOST_INTRUSIVE_STATIC_ASSERT(!(cache_last && ((int)value_traits::link_mode == (int)auto_unlink)));
- inline node_ptr get_end_node()
- { return node_algorithms::end_node(this->get_root_node()); }
- inline const_node_ptr get_end_node() const
- { return node_algorithms::end_node(this->get_root_node()); }
- inline node_ptr get_root_node()
- { return data_.root_plus_size_.header_holder_.get_node(); }
- inline const_node_ptr get_root_node() const
- { return data_.root_plus_size_.header_holder_.get_node(); }
- inline node_ptr get_last_node()
- { return this->get_last_node(detail::bool_<cache_last>()); }
- inline const_node_ptr get_last_node() const
- { return this->get_last_node(detail::bool_<cache_last>()); }
- inline void set_last_node(node_ptr n)
- { return this->set_last_node(n, detail::bool_<cache_last>()); }
- inline static node_ptr get_last_node(detail::bool_<false>)
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- return node_ptr();
- }
- inline static void set_last_node(node_ptr , detail::bool_<false>)
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- }
- inline node_ptr get_last_node(detail::bool_<true>)
- { return node_ptr(data_.root_plus_size_.last_); }
- inline const_node_ptr get_last_node(detail::bool_<true>) const
- { return const_node_ptr(data_.root_plus_size_.last_); }
- inline void set_last_node(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));
- BOOST_IF_CONSTEXPR(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_;
- inline size_traits &priv_size_traits()
- { return data_.root_plus_size_; }
- inline const size_traits &priv_size_traits() const
- { return data_.root_plus_size_; }
- inline const value_traits &priv_value_traits() const
- { return data_; }
- inline value_traits &priv_value_traits()
- { return data_; }
- typedef typename boost::intrusive::value_traits_pointers
- <ValueTraits>::const_value_traits_ptr const_value_traits_ptr;
- inline 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( node_ptr f, 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);
- BOOST_IF_CONSTEXPR(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()
- {
- BOOST_IF_CONSTEXPR(is_safe_autounlink<ValueTraits::link_mode>::value){
- this->clear();
- node_algorithms::init(this->get_root_node());
- }
- }
-
-
-
-
-
-
-
-
- void clear() BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(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) BOOST_NOEXCEPT
- {
- node_algorithms::detach_and_dispose
- ( this->get_root_node()
- , detail::node_disposer<Disposer, value_traits, CommonSListAlgorithms>
- (disposer, &this->priv_value_traits()) );
- this->set_default_constructed_state();
- }
-
-
-
-
-
-
-
-
-
-
- void push_front(reference value) BOOST_NOEXCEPT
- {
- 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));
- BOOST_IF_CONSTEXPR(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_NOEXCEPT
- {
- BOOST_INTRUSIVE_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);
- BOOST_IF_CONSTEXPR(cache_last){
- this->set_last_node(n);
- }
- this->priv_size_traits().increment();
- }
-
-
-
-
-
-
-
-
- void pop_front() BOOST_NOEXCEPT
- { return this->pop_front_and_dispose(detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- void pop_front_and_dispose(Disposer disposer) BOOST_NOEXCEPT
- {
- 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();
- BOOST_IF_CONSTEXPR(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- disposer(priv_value_traits().to_value_ptr(to_erase));
- BOOST_IF_CONSTEXPR(cache_last){
- if(this->empty()){
- this->set_last_node(this->get_root_node());
- }
- }
- }
-
-
-
-
-
- inline reference front() BOOST_NOEXCEPT
- { return *this->priv_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); }
-
-
-
-
-
- inline const_reference front() const BOOST_NOEXCEPT
- { return *this->priv_value_traits().to_value_ptr(detail::uncast(node_traits::get_next(this->get_root_node()))); }
-
-
-
-
-
-
-
-
- reference back() BOOST_NOEXCEPT
- {
- BOOST_INTRUSIVE_STATIC_ASSERT((cache_last));
- return *this->priv_value_traits().to_value_ptr(this->get_last_node());
- }
-
-
-
-
-
-
-
-
- inline const_reference back() const BOOST_NOEXCEPT
- {
- BOOST_INTRUSIVE_STATIC_ASSERT((cache_last));
- return *this->priv_value_traits().to_value_ptr(this->get_last_node());
- }
-
-
-
-
-
- inline iterator begin() BOOST_NOEXCEPT
- { return iterator (node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- inline const_iterator begin() const BOOST_NOEXCEPT
- { return const_iterator (node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- inline const_iterator cbegin() const BOOST_NOEXCEPT
- { return const_iterator(node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- inline iterator end() BOOST_NOEXCEPT
- { return iterator(this->get_end_node(), this->priv_value_traits_ptr()); }
-
-
-
-
-
- inline const_iterator end() const BOOST_NOEXCEPT
- { return const_iterator(detail::uncast(this->get_end_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
- inline const_iterator cend() const BOOST_NOEXCEPT
- { return this->end(); }
-
-
-
-
-
-
- inline iterator before_begin() BOOST_NOEXCEPT
- { return iterator(this->get_root_node(), this->priv_value_traits_ptr()); }
-
-
-
-
-
-
- inline const_iterator before_begin() const BOOST_NOEXCEPT
- { return const_iterator(detail::uncast(this->get_root_node()), this->priv_value_traits_ptr()); }
-
-
-
-
-
-
- inline const_iterator cbefore_begin() const BOOST_NOEXCEPT
- { return this->before_begin(); }
-
-
-
-
-
-
-
- inline iterator last() BOOST_NOEXCEPT
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- return iterator (this->get_last_node(), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
- inline const_iterator last() const BOOST_NOEXCEPT
- {
-
- BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
- return const_iterator (this->get_last_node(), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
- inline const_iterator clast() const BOOST_NOEXCEPT
- { return const_iterator(this->get_last_node(), this->priv_value_traits_ptr()); }
-
-
-
-
-
-
-
-
- inline static slist_impl &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT
- { return slist_impl::priv_container_from_end_iterator(end_iterator); }
-
-
-
-
-
-
-
-
- inline static const slist_impl &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT
- { return slist_impl::priv_container_from_end_iterator(end_iterator); }
-
-
-
-
-
-
-
-
- inline size_type size() const BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(constant_time_size)
- return this->priv_size_traits().get_size();
- else
- return node_algorithms::count(this->get_root_node()) - 1;
- }
-
-
-
-
-
-
-
- inline bool empty() const BOOST_NOEXCEPT
- { return node_algorithms::is_empty(this->get_root_node()); }
-
-
-
-
-
-
-
-
- void swap(slist_impl& other)
- {
- BOOST_IF_CONSTEXPR(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) BOOST_NOEXCEPT
- { this->priv_shift_backwards(n, detail::bool_<linear>()); }
-
-
-
-
-
-
-
-
-
- void shift_forward(size_type n = 1) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- {
- 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) BOOST_NOEXCEPT
- {
-
- 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);
- }
- BOOST_IF_CONSTEXPR(constant_time_size){
- this->priv_size_traits().increase(count);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, reference value) BOOST_NOEXCEPT
- { return this->insert_after(this->previous(p), value); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- void insert(const_iterator p, Iterator b, Iterator e) BOOST_NOEXCEPT
- { return this->insert_after(this->previous(p), b, e); }
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase_after(const_iterator prev) BOOST_NOEXCEPT
- { return this->erase_after_and_dispose(prev, detail::null_disposer()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase_after(const_iterator before_f, const_iterator l) BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(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();
- BOOST_IF_CONSTEXPR(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_NOEXCEPT
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance((++const_iterator(before_f)).pointed_node(), l.pointed_node()) == n);
- (void)n;
- BOOST_IF_CONSTEXPR(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();
- BOOST_IF_CONSTEXPR(cache_last){
- if((lp == this->get_end_node())){
- this->set_last_node(bfp);
- }
- }
- node_algorithms::unlink_after(bfp, lp);
- BOOST_IF_CONSTEXPR(constant_time_size){
- this->priv_size_traits().decrease(n);
- }
- return l.unconst();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator i) BOOST_NOEXCEPT
- { return this->erase_after(this->previous(i)); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator f, const_iterator l) BOOST_NOEXCEPT
- { return this->erase_after(this->previous(f), l); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator f, const_iterator l, size_type n) BOOST_NOEXCEPT
- { return this->erase_after(this->previous(f), l, n); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_after_and_dispose(const_iterator prev, Disposer disposer) BOOST_NOEXCEPT
- {
- 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);
- }
- BOOST_IF_CONSTEXPR(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_NOEXCEPT
- {
- BOOST_INTRUSIVE_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_NOEXCEPT
- {
- BOOST_INTRUSIVE_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);
- BOOST_IF_CONSTEXPR(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_NOEXCEPT
- {
- BOOST_INTRUSIVE_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);
- BOOST_IF_CONSTEXPR(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) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- {
- 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);
- BOOST_IF_CONSTEXPR(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) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- {
- 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());
- BOOST_IF_CONSTEXPR(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) BOOST_NOEXCEPT
- {
- 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) BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(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_NOEXCEPT
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node()) == n);
- (void)n;
- this->priv_splice_after
- (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node());
- BOOST_IF_CONSTEXPR(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) BOOST_NOEXCEPT
- { this->splice_after(this->previous(it), x, l); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator pos, slist_impl &x, const_iterator elem) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- { 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) BOOST_NOEXCEPT
- { 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()));
- BOOST_IF_CONSTEXPR(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()));
- BOOST_IF_CONSTEXPR(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() BOOST_NOEXCEPT
- {
- 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) BOOST_NOEXCEPT
- { this->remove_if(detail::equal_to_value<const_reference>(value)); }
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- void remove_and_dispose(const_reference value, Disposer disposer) BOOST_NOEXCEPT
- { 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);
-
- BOOST_IF_CONSTEXPR(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);
-
- BOOST_IF_CONSTEXPR(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;
- }
- }
- BOOST_IF_CONSTEXPR(cache_last){
- this->set_last_node(bcur.pointed_node());
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
- static iterator s_iterator_to(reference value) BOOST_NOEXCEPT
- {
- BOOST_INTRUSIVE_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_NOEXCEPT
- {
- BOOST_INTRUSIVE_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_NOEXCEPT
- {
- 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 BOOST_NOEXCEPT
- {
- 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) BOOST_NOEXCEPT
- { return this->previous(this->cbefore_begin(), i); }
-
-
-
-
-
-
-
-
- const_iterator previous(const_iterator i) const BOOST_NOEXCEPT
- { return this->previous(this->cbefore_begin(), i); }
-
-
-
-
-
-
-
-
-
- iterator previous(const_iterator prev_from, iterator i) BOOST_NOEXCEPT
- { return this->previous(prev_from, const_iterator(i)).unconst(); }
-
-
-
-
-
-
-
-
-
- const_iterator previous(const_iterator prev_from, const_iterator i) const BOOST_NOEXCEPT
- {
- 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, node_ptr f, node_ptr before_l) BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(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, node_ptr f, node_ptr before_l, size_type n) BOOST_NOEXCEPT
- {
- 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);
- BOOST_IF_CONSTEXPR(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; (void)node_count;
- const_node_ptr p = header_ptr;
- while (true)
- {
- const_node_ptr next_p = node_traits::get_next(p);
- BOOST_IF_CONSTEXPR(!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)
- {
- BOOST_IF_CONSTEXPR(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);
- BOOST_IF_CONSTEXPR(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);
- BOOST_IF_CONSTEXPR(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_INTRUSIVE_STATIC_ASSERT(!linear);
- BOOST_INTRUSIVE_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_INTRUSIVE_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;
- inline slist()
- : Base()
- {}
- inline explicit slist(const value_traits &v_traits)
- : Base(v_traits)
- {}
- struct incorporate_t{};
- inline slist( node_ptr f, node_ptr before_l
- , size_type n, const value_traits &v_traits = value_traits())
- : Base(f, before_l, n, v_traits)
- {}
- template<class Iterator>
- inline slist(Iterator b, Iterator e, const value_traits &v_traits = value_traits())
- : Base(b, e, v_traits)
- {}
- inline slist(BOOST_RV_REF(slist) x)
- : Base(BOOST_MOVE_BASE(Base, x))
- {}
- inline slist& operator=(BOOST_RV_REF(slist) x)
- { return static_cast<slist &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
- template <class Cloner, class Disposer>
- inline void clone_from(const slist &src, Cloner cloner, Disposer disposer)
- { Base::clone_from(src, cloner, disposer); }
- template <class Cloner, class Disposer>
- inline void clone_from(BOOST_RV_REF(slist) src, Cloner cloner, Disposer disposer)
- { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
- inline static slist &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT
- { return static_cast<slist &>(Base::container_from_end_iterator(end_iterator)); }
- inline static const slist &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT
- { return static_cast<const slist &>(Base::container_from_end_iterator(end_iterator)); }
- };
- #endif
- }
- }
- #include <boost/intrusive/detail/config_end.hpp>
- #endif
|