12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237 |
- #ifndef BOOST_INTRUSIVE_BSTREE_HPP
- #define BOOST_INTRUSIVE_BSTREE_HPP
- #include <boost/intrusive/detail/config_begin.hpp>
- #include <boost/intrusive/intrusive_fwd.hpp>
- #include <boost/intrusive/detail/assert.hpp>
- #include <boost/intrusive/intrusive_fwd.hpp>
- #include <boost/intrusive/bs_set_hook.hpp>
- #include <boost/intrusive/detail/tree_node.hpp>
- #include <boost/intrusive/detail/tree_iterator.hpp>
- #include <boost/intrusive/detail/ebo_functor_holder.hpp>
- #include <boost/intrusive/detail/mpl.hpp>
- #include <boost/intrusive/pointer_traits.hpp>
- #include <boost/intrusive/detail/is_stateful_value_traits.hpp>
- #include <boost/intrusive/detail/empty_node_checker.hpp>
- #include <boost/intrusive/detail/default_header_holder.hpp>
- #include <boost/intrusive/detail/reverse_iterator.hpp>
- #include <boost/intrusive/detail/exception_disposer.hpp>
- #include <boost/intrusive/detail/node_cloner_disposer.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/algo_type.hpp>
- #include <boost/intrusive/detail/algorithm.hpp>
- #include <boost/intrusive/detail/tree_value_compare.hpp>
- #include <boost/intrusive/detail/get_value_traits.hpp>
- #include <boost/intrusive/bstree_algorithms.hpp>
- #include <boost/intrusive/link_mode.hpp>
- #include <boost/intrusive/parent_from_member.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/move/adl_move_swap.hpp>
- #include <boost/intrusive/detail/minimal_pair_header.hpp>
- #include <cstddef> //size_t...
- #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal_to
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- namespace boost {
- namespace intrusive {
- struct default_bstree_hook_applier
- { template <class T> struct apply{ typedef typename T::default_bstree_hook type; }; };
- template<>
- struct is_default_hook_tag<default_bstree_hook_applier>
- { static const bool value = true; };
- struct bstree_defaults
- {
- typedef default_bstree_hook_applier proto_value_traits;
- static const bool constant_time_size = true;
- typedef std::size_t size_type;
- typedef void compare;
- typedef void key_of_value;
- static const bool floating_point = true;
- typedef void priority;
- typedef void header_holder_type;
- };
- template<class ValueTraits, algo_types AlgoType, typename HeaderHolder>
- struct bstbase3
- {
- typedef ValueTraits value_traits;
- typedef typename value_traits::node_traits node_traits;
- typedef typename node_traits::node node_type;
- typedef typename get_algo<AlgoType, node_traits>::type node_algorithms;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename node_traits::const_node_ptr const_node_ptr;
- typedef tree_iterator<value_traits, false> iterator;
- typedef tree_iterator<value_traits, true> const_iterator;
- typedef boost::intrusive::reverse_iterator<iterator> reverse_iterator;
- typedef boost::intrusive::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer;
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
- typedef typename detail::get_header_holder_type
- < value_traits,HeaderHolder >::type header_holder_type;
- static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
- static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
- static const bool has_container_from_iterator =
- detail::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value;
- struct holder_t : public ValueTraits
- {
- inline explicit holder_t(const ValueTraits &vtraits)
- : ValueTraits(vtraits)
- {}
- header_holder_type root;
- } holder;
- static bstbase3 &get_tree_base_from_end_iterator(const const_iterator &end_iterator)
- {
- 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);
- holder_t *holder = get_parent_from_member<holder_t, header_holder_type>(h, &holder_t::root);
- bstbase3 *base = get_parent_from_member<bstbase3, holder_t> (holder, &bstbase3::holder);
- return *base;
- }
- inline bstbase3(const ValueTraits &vtraits)
- : holder(vtraits)
- {
- node_algorithms::init_header(this->header_ptr());
- }
- inline node_ptr header_ptr()
- { return holder.root.get_node(); }
- inline const_node_ptr header_ptr() const
- { return holder.root.get_node(); }
- inline const value_traits &get_value_traits() const
- { return this->holder; }
- inline value_traits &get_value_traits()
- { return this->holder; }
- 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->get_value_traits()); }
- inline iterator begin() BOOST_NOEXCEPT
- { return iterator(node_algorithms::begin_node(this->header_ptr()), this->priv_value_traits_ptr()); }
- inline const_iterator begin() const BOOST_NOEXCEPT
- { return cbegin(); }
- inline const_iterator cbegin() const BOOST_NOEXCEPT
- { return const_iterator(node_algorithms::begin_node(this->header_ptr()), this->priv_value_traits_ptr()); }
- inline iterator end() BOOST_NOEXCEPT
- { return iterator(node_algorithms::end_node(this->header_ptr()), this->priv_value_traits_ptr()); }
- inline const_iterator end() const BOOST_NOEXCEPT
- { return cend(); }
- inline const_iterator cend() const BOOST_NOEXCEPT
- { return const_iterator(node_algorithms::end_node(this->header_ptr()), this->priv_value_traits_ptr()); }
- inline iterator root()
- { return iterator(node_algorithms::root_node(this->header_ptr()), this->priv_value_traits_ptr()); }
- inline const_iterator root() const
- { return croot(); }
- inline const_iterator croot() const
- { return const_iterator(node_algorithms::root_node(this->header_ptr()), this->priv_value_traits_ptr()); }
- inline reverse_iterator rbegin()
- { return reverse_iterator(end()); }
- inline const_reverse_iterator rbegin() const
- { return const_reverse_iterator(end()); }
- inline const_reverse_iterator crbegin() const
- { return const_reverse_iterator(end()); }
- inline reverse_iterator rend()
- { return reverse_iterator(begin()); }
- inline const_reverse_iterator rend() const
- { return const_reverse_iterator(begin()); }
- inline const_reverse_iterator crend() const
- { return const_reverse_iterator(begin()); }
- void replace_node(iterator replace_this, reference with_this)
- {
- node_algorithms::replace_node( get_value_traits().to_node_ptr(*replace_this)
- , this->header_ptr()
- , get_value_traits().to_node_ptr(with_this));
- BOOST_IF_CONSTEXPR(safemode_or_autounlink)
- node_algorithms::init(replace_this.pointed_node());
- }
- inline void rebalance() BOOST_NOEXCEPT
- { node_algorithms::rebalance(this->header_ptr()); }
- iterator rebalance_subtree(iterator r) BOOST_NOEXCEPT
- { return iterator(node_algorithms::rebalance_subtree(r.pointed_node()), this->priv_value_traits_ptr()); }
- 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));
- return const_iterator (value_traits::to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value))), const_value_traits_ptr());
- }
- iterator iterator_to(reference value) BOOST_NOEXCEPT
- { return iterator (this->get_value_traits().to_node_ptr(value), this->priv_value_traits_ptr()); }
- const_iterator iterator_to(const_reference value) const BOOST_NOEXCEPT
- { return const_iterator (this->get_value_traits().to_node_ptr(*pointer_traits<pointer>::const_cast_from(pointer_traits<const_pointer>::pointer_to(value))), this->priv_value_traits_ptr()); }
- inline static void init_node(reference value)
- { node_algorithms::init(value_traits::to_node_ptr(value)); }
- };
- template<class Less, class T>
- struct get_compare
- {
- typedef Less type;
- };
- template<class T>
- struct get_compare<void, T>
- {
- typedef ::std::less<T> type;
- };
- template<class KeyOfValue, class T>
- struct get_key_of_value
- {
- typedef KeyOfValue type;
- };
- template<class T>
- struct get_key_of_value<void, T>
- {
- typedef ::boost::intrusive::detail::identity<T> type;
- };
- template<class ValuePtr, class VoidOrKeyOfValue, class VoidOrKeyComp>
- struct bst_key_types
- {
- typedef typename
- boost::movelib::pointer_element<ValuePtr>::type value_type;
- typedef typename get_key_of_value
- < VoidOrKeyOfValue, value_type>::type key_of_value;
- typedef typename key_of_value::type key_type;
- typedef typename get_compare< VoidOrKeyComp
- , key_type
- >::type key_compare;
- typedef tree_value_compare
- <ValuePtr, key_compare, key_of_value> value_compare;
- };
- template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, algo_types AlgoType, typename HeaderHolder>
- struct bstbase2
-
-
- : public detail::ebo_functor_holder
- < typename bst_key_types
- < typename ValueTraits::pointer
- , VoidOrKeyOfValue
- , VoidOrKeyComp
-
- >::value_compare
- >
- , public bstbase3<ValueTraits, AlgoType, HeaderHolder>
- {
- typedef bstbase3<ValueTraits, AlgoType, HeaderHolder> treeheader_t;
- typedef bst_key_types< typename ValueTraits::pointer
- , VoidOrKeyOfValue
- , VoidOrKeyComp> key_types;
- typedef typename treeheader_t::value_traits value_traits;
- typedef typename treeheader_t::node_algorithms node_algorithms;
- typedef typename ValueTraits::value_type value_type;
- typedef typename key_types::key_type key_type;
- typedef typename key_types::key_of_value key_of_value;
- typedef typename key_types::key_compare key_compare;
- typedef typename key_types::value_compare value_compare;
- typedef typename treeheader_t::iterator iterator;
- typedef typename treeheader_t::const_iterator const_iterator;
- typedef typename treeheader_t::node_ptr node_ptr;
- typedef typename treeheader_t::const_node_ptr const_node_ptr;
- bstbase2(const key_compare &comp, const ValueTraits &vtraits)
- : detail::ebo_functor_holder<value_compare>(value_compare(comp)), treeheader_t(vtraits)
- {}
- const value_compare &get_comp() const
- { return this->get(); }
- value_compare &get_comp()
- { return this->get(); }
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer;
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
- typedef typename node_algorithms::insert_commit_data insert_commit_data;
- inline value_compare value_comp() const
- { return this->get_comp(); }
- inline key_compare key_comp() const
- { return this->get_comp().key_comp(); }
-
- inline iterator lower_bound(const key_type &key)
- { return this->lower_bound(key, this->key_comp()); }
- inline const_iterator lower_bound(const key_type &key) const
- { return this->lower_bound(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp)
- {
- return iterator(node_algorithms::lower_bound
- (this->header_ptr(), key, this->key_node_comp(comp)), this->priv_value_traits_ptr());
- }
- template<class KeyType, class KeyTypeKeyCompare>
- const_iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp) const
- {
- return const_iterator(node_algorithms::lower_bound
- (this->header_ptr(), key, this->key_node_comp(comp)), this->priv_value_traits_ptr());
- }
-
- inline iterator upper_bound(const key_type &key)
- { return this->upper_bound(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp)
- {
- return iterator(node_algorithms::upper_bound
- (this->header_ptr(), key, this->key_node_comp(comp)), this->priv_value_traits_ptr());
- }
- inline const_iterator upper_bound(const key_type &key) const
- { return this->upper_bound(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- const_iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp) const
- {
- return const_iterator(node_algorithms::upper_bound
- (this->header_ptr(), key, this->key_node_comp(comp)), this->priv_value_traits_ptr());
- }
- template<class KeyTypeKeyCompare>
- struct key_node_comp_ret
- { typedef detail::key_nodeptr_comp<KeyTypeKeyCompare, value_traits, key_of_value> type; };
- template<class KeyTypeKeyCompare>
- inline typename key_node_comp_ret<KeyTypeKeyCompare>::type key_node_comp(KeyTypeKeyCompare comp) const
- {
- return detail::key_nodeptr_comp<KeyTypeKeyCompare, value_traits, key_of_value>(comp, &this->get_value_traits());
- }
-
- inline iterator find(const key_type &key)
- { return this->find(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- iterator find(const KeyType &key, KeyTypeKeyCompare comp)
- {
- return iterator
- (node_algorithms::find(this->header_ptr(), key, this->key_node_comp(comp)), this->priv_value_traits_ptr());
- }
- inline const_iterator find(const key_type &key) const
- { return this->find(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- const_iterator find(const KeyType &key, KeyTypeKeyCompare comp) const
- {
- return const_iterator
- (node_algorithms::find(this->header_ptr(), key, this->key_node_comp(comp)), this->priv_value_traits_ptr());
- }
-
- inline std::pair<iterator,iterator> equal_range(const key_type &key)
- { return this->equal_range(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator,iterator> equal_range(const KeyType &key, KeyTypeKeyCompare comp)
- {
- std::pair<node_ptr, node_ptr> ret =
- node_algorithms::equal_range(this->header_ptr(), key, this->key_node_comp(comp));
- return std::pair<iterator, iterator>( iterator(ret.first, this->priv_value_traits_ptr())
- , iterator(ret.second, this->priv_value_traits_ptr()));
- }
- inline std::pair<const_iterator, const_iterator>
- equal_range(const key_type &key) const
- { return this->equal_range(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<const_iterator, const_iterator>
- equal_range(const KeyType &key, KeyTypeKeyCompare comp) const
- {
- std::pair<node_ptr, node_ptr> ret =
- node_algorithms::equal_range(this->header_ptr(), key, this->key_node_comp(comp));
- return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->priv_value_traits_ptr())
- , const_iterator(ret.second, this->priv_value_traits_ptr()));
- }
-
- inline std::pair<iterator,iterator> lower_bound_range(const key_type &key)
- { return this->lower_bound_range(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator,iterator> lower_bound_range(const KeyType &key, KeyTypeKeyCompare comp)
- {
- std::pair<node_ptr, node_ptr> ret =
- node_algorithms::lower_bound_range(this->header_ptr(), key, this->key_node_comp(comp));
- return std::pair<iterator, iterator>( iterator(ret.first, this->priv_value_traits_ptr())
- , iterator(ret.second, this->priv_value_traits_ptr()));
- }
- inline std::pair<const_iterator, const_iterator>
- lower_bound_range(const key_type &key) const
- { return this->lower_bound_range(key, this->key_comp()); }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<const_iterator, const_iterator>
- lower_bound_range(const KeyType &key, KeyTypeKeyCompare comp) const
- {
- std::pair<node_ptr, node_ptr> ret =
- node_algorithms::lower_bound_range(this->header_ptr(), key, this->key_node_comp(comp));
- return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->priv_value_traits_ptr())
- , const_iterator(ret.second, this->priv_value_traits_ptr()));
- }
-
- inline std::pair<iterator,iterator> bounded_range
- (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed)
- { return this->bounded_range(lower_key, upper_key, this->key_comp(), left_closed, right_closed); }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator,iterator> bounded_range
- (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed)
- {
- std::pair<node_ptr, node_ptr> ret =
- node_algorithms::bounded_range
- (this->header_ptr(), lower_key, upper_key, this->key_node_comp(comp), left_closed, right_closed);
- return std::pair<iterator, iterator>( iterator(ret.first, this->priv_value_traits_ptr())
- , iterator(ret.second, this->priv_value_traits_ptr()));
- }
- inline std::pair<const_iterator,const_iterator> bounded_range
- (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const
- { return this->bounded_range(lower_key, upper_key, this->key_comp(), left_closed, right_closed); }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<const_iterator,const_iterator> bounded_range
- (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const
- {
- std::pair<node_ptr, node_ptr> ret =
- node_algorithms::bounded_range
- (this->header_ptr(), lower_key, upper_key, this->key_node_comp(comp), left_closed, right_closed);
- return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->priv_value_traits_ptr())
- , const_iterator(ret.second, this->priv_value_traits_ptr()));
- }
-
- inline std::pair<iterator, bool> insert_unique_check
- (const key_type &key, insert_commit_data &commit_data)
- { return this->insert_unique_check(key, this->key_comp(), commit_data); }
- inline std::pair<iterator, bool> insert_unique_check
- (const_iterator hint, const key_type &key, insert_commit_data &commit_data)
- { return this->insert_unique_check(hint, key, this->key_comp(), commit_data); }
- template<class KeyType, class KeyTypeKeyCompare>
- BOOST_INTRUSIVE_DOC1ST(std::pair<iterator BOOST_INTRUSIVE_I bool>
- , typename detail::disable_if_convertible
- <KeyType BOOST_INTRUSIVE_I const_iterator BOOST_INTRUSIVE_I
- std::pair<iterator BOOST_INTRUSIVE_I bool> >::type)
- insert_unique_check
- (const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data)
- {
- std::pair<node_ptr, bool> ret =
- (node_algorithms::insert_unique_check
- (this->header_ptr(), key, this->key_node_comp(comp), commit_data));
- return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second);
- }
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator, bool> insert_unique_check
- (const_iterator hint, const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data)
- {
- std::pair<node_ptr, bool> ret =
- (node_algorithms::insert_unique_check
- (this->header_ptr(), hint.pointed_node(), key, this->key_node_comp(comp), commit_data));
- return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second);
- }
- };
- template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType, typename HeaderHolder>
- struct bstbase_hack
- : public detail::size_holder<ConstantTimeSize, SizeType>
- , public bstbase2 < ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, AlgoType, HeaderHolder>
- {
- typedef bstbase2< ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, AlgoType, HeaderHolder> base_type;
- typedef typename base_type::key_compare key_compare;
- typedef typename base_type::value_compare value_compare;
- typedef SizeType size_type;
- typedef typename base_type::node_traits node_traits;
- typedef typename get_algo
- <AlgoType, node_traits>::type algo_type;
- inline bstbase_hack(const key_compare & comp, const ValueTraits &vtraits)
- : base_type(comp, vtraits)
- {
- this->sz_traits().set_size(size_type(0));
- }
- typedef detail::size_holder<ConstantTimeSize, SizeType> size_traits;
- inline size_traits &sz_traits()
- { return static_cast<size_traits &>(*this); }
- inline const size_traits &sz_traits() const
- { return static_cast<const size_traits &>(*this); }
- };
- template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, class SizeType, algo_types AlgoType, typename HeaderHolder>
- struct bstbase_hack<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, false, SizeType, AlgoType, HeaderHolder>
- : public bstbase2 < ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, AlgoType, HeaderHolder>
- {
- typedef bstbase2< ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, AlgoType, HeaderHolder> base_type;
- typedef typename base_type::value_compare value_compare;
- typedef typename base_type::key_compare key_compare;
- inline bstbase_hack(const key_compare & comp, const ValueTraits &vtraits)
- : base_type(comp, vtraits)
- {}
- typedef detail::size_holder<false, SizeType> size_traits;
- inline size_traits sz_traits() const
- { return size_traits(); }
- };
- template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType, typename HeaderHolder>
- struct bstbase
- : public bstbase_hack< ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, HeaderHolder>
- {
- typedef bstbase_hack< ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, HeaderHolder> base_type;
- typedef ValueTraits value_traits;
- typedef typename base_type::value_compare value_compare;
- typedef typename base_type::key_compare key_compare;
- typedef typename base_type::const_reference const_reference;
- typedef typename base_type::reference reference;
- typedef typename base_type::iterator iterator;
- typedef typename base_type::const_iterator const_iterator;
- typedef typename base_type::node_traits node_traits;
- typedef typename get_algo
- <AlgoType, node_traits>::type node_algorithms;
- typedef SizeType size_type;
- inline bstbase(const key_compare & comp, const ValueTraits &vtraits)
- : base_type(comp, vtraits)
- {}
-
-
- ~bstbase()
- {
- if(is_safe_autounlink<value_traits::link_mode>::value){
- node_algorithms::clear_and_dispose
- ( this->header_ptr()
- , detail::node_disposer<detail::null_disposer, value_traits, AlgoType>
- (detail::null_disposer(), &this->get_value_traits()));
- node_algorithms::init(this->header_ptr());
- }
- }
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- template<class T, class ...Options>
- #else
- template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType, typename HeaderHolder>
- #endif
- class bstree_impl
- : public bstbase<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, HeaderHolder>
- {
- public:
-
- typedef bstbase<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, HeaderHolder> data_type;
- typedef tree_iterator<ValueTraits, false> iterator_type;
- typedef tree_iterator<ValueTraits, true> const_iterator_type;
-
- typedef BOOST_INTRUSIVE_IMPDEF(ValueTraits) value_traits;
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer;
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
- typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::key_type) key_type;
- typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::key_of_value) key_of_value;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
- typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
- typedef BOOST_INTRUSIVE_IMPDEF(SizeType) size_type;
- typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::value_compare) value_compare;
- typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::key_compare) key_compare;
- typedef BOOST_INTRUSIVE_IMPDEF(iterator_type) iterator;
- typedef BOOST_INTRUSIVE_IMPDEF(const_iterator_type) const_iterator;
- typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::reverse_iterator<const_iterator>) const_reverse_iterator;
- typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::node_traits) node_traits;
- typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node) node;
- typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node_ptr) node_ptr;
- typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::const_node_ptr) const_node_ptr;
-
- typedef typename get_algo<AlgoType, node_traits>::type algo_type;
-
- typedef BOOST_INTRUSIVE_IMPDEF(algo_type) node_algorithms;
- static const bool constant_time_size = ConstantTimeSize;
- static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
-
- private:
-
- BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree_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)));
- protected:
-
- public:
- typedef typename node_algorithms::insert_commit_data insert_commit_data;
-
-
-
-
-
-
-
- bstree_impl()
- : data_type(key_compare(), value_traits())
- {}
-
-
-
-
-
-
-
- explicit bstree_impl( const key_compare &cmp, const value_traits &v_traits = value_traits())
- : data_type(cmp, v_traits)
- {}
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- bstree_impl( bool unique, Iterator b, Iterator e
- , const key_compare &cmp = key_compare()
- , const value_traits &v_traits = value_traits())
- : data_type(cmp, v_traits)
- {
-
- if(unique)
- this->insert_unique(b, e);
- else
- this->insert_equal(b, e);
- }
-
-
-
-
-
-
-
-
-
- bstree_impl(BOOST_RV_REF(bstree_impl) x)
- : data_type(::boost::move(x.get_comp()), ::boost::move(x.get_value_traits()))
- {
- this->swap(x);
- }
-
-
- inline bstree_impl& operator=(BOOST_RV_REF(bstree_impl) x)
- { this->swap(x); return *this; }
- #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
-
-
-
-
-
-
-
- ~bstree_impl()
- {}
-
-
-
-
-
- iterator begin() BOOST_NOEXCEPT;
-
-
-
-
-
- const_iterator begin() const BOOST_NOEXCEPT;
-
-
-
-
-
- const_iterator cbegin() const BOOST_NOEXCEPT;
-
-
-
-
-
- iterator end() BOOST_NOEXCEPT;
-
-
-
-
-
- const_iterator end() const BOOST_NOEXCEPT;
-
-
-
-
-
- const_iterator cend() const BOOST_NOEXCEPT;
-
-
-
-
-
-
- reverse_iterator rbegin() BOOST_NOEXCEPT;
-
-
-
-
-
-
- const_reverse_iterator rbegin() const BOOST_NOEXCEPT;
-
-
-
-
-
-
- const_reverse_iterator crbegin() const BOOST_NOEXCEPT;
-
-
-
-
-
-
- reverse_iterator rend() BOOST_NOEXCEPT;
-
-
-
-
-
-
- const_reverse_iterator rend() const BOOST_NOEXCEPT;
-
-
-
-
-
-
- const_reverse_iterator crend() const BOOST_NOEXCEPT;
-
-
-
-
-
- iterator root() BOOST_NOEXCEPT;
-
-
-
-
-
- const_iterator root() const BOOST_NOEXCEPT;
-
-
-
-
-
- const_iterator croot() const BOOST_NOEXCEPT;
- #endif
-
-
-
-
-
-
-
-
- static bstree_impl &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT
- {
- return static_cast<bstree_impl&>
- (data_type::get_tree_base_from_end_iterator(end_iterator));
- }
-
-
-
-
-
-
-
-
- static const bstree_impl &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT
- {
- return static_cast<bstree_impl&>
- (data_type::get_tree_base_from_end_iterator(end_iterator));
- }
-
-
-
-
-
-
-
-
- static bstree_impl &container_from_iterator(iterator it) BOOST_NOEXCEPT
- { return container_from_end_iterator(it.end_iterator_from_it()); }
-
-
-
-
-
-
-
-
- static const bstree_impl &container_from_iterator(const_iterator it) BOOST_NOEXCEPT
- { return container_from_end_iterator(it.end_iterator_from_it()); }
- #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
-
-
-
-
-
- key_compare key_comp() const;
-
-
-
-
-
- value_compare value_comp() const;
- #endif
-
-
-
-
-
- bool empty() const BOOST_NOEXCEPT
- {
- if(ConstantTimeSize){
- return !this->data_type::sz_traits().get_size();
- }
- else{
- return algo_type::unique(this->header_ptr());
- }
- }
-
-
-
-
-
-
- size_type size() const BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(constant_time_size)
- return this->sz_traits().get_size();
- else{
- return (size_type)node_algorithms::size(this->header_ptr());
- }
- }
-
-
-
-
-
- void swap(bstree_impl& other)
- {
-
- ::boost::adl_move_swap(this->get_comp(), other.get_comp());
-
- node_algorithms::swap_tree(this->header_ptr(), node_ptr(other.header_ptr()));
- this->sz_traits().swap(other.sz_traits());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class Cloner, class Disposer>
- void clone_from(const bstree_impl &src, Cloner cloner, Disposer disposer)
- {
- this->clear_and_dispose(disposer);
- if(!src.empty()){
- detail::exception_disposer<bstree_impl, Disposer>
- rollback(*this, disposer);
- node_algorithms::clone
- (src.header_ptr()
- ,this->header_ptr()
- ,detail::node_cloner <Cloner, value_traits, AlgoType>(cloner, &this->get_value_traits())
- ,detail::node_disposer<Disposer, value_traits, AlgoType>(disposer, &this->get_value_traits()));
- this->sz_traits().set_size(src.sz_traits().get_size());
- this->get_comp() = src.get_comp();
- rollback.release();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class Cloner, class Disposer>
- void clone_from(BOOST_RV_REF(bstree_impl) src, Cloner cloner, Disposer disposer)
- {
- this->clear_and_dispose(disposer);
- if(!src.empty()){
- detail::exception_disposer<bstree_impl, Disposer>
- rollback(*this, disposer);
- node_algorithms::clone
- (src.header_ptr()
- ,this->header_ptr()
- ,detail::node_cloner <Cloner, value_traits, AlgoType, false>(cloner, &this->get_value_traits())
- ,detail::node_disposer<Disposer, value_traits, AlgoType>(disposer, &this->get_value_traits()));
- this->sz_traits().set_size(src.sz_traits().get_size());
- this->get_comp() = src.get_comp();
- rollback.release();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
- iterator insert_equal(reference value)
- {
- node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
- iterator ret(node_algorithms::insert_equal_upper_bound
- (this->header_ptr(), to_insert, this->key_node_comp(this->key_comp())), this->priv_value_traits_ptr());
- this->sz_traits().increment();
- return ret;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert_equal(const_iterator hint, reference value)
- {
- node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
- iterator ret(node_algorithms::insert_equal
- (this->header_ptr(), hint.pointed_node(), to_insert, this->key_node_comp(this->key_comp())), this->priv_value_traits_ptr());
- this->sz_traits().increment();
- return ret;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- void insert_equal(Iterator b, Iterator e)
- {
- iterator iend(this->end());
- for (; b != e; ++b)
- this->insert_equal(iend, *b);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- std::pair<iterator, bool> insert_unique(reference value)
- {
- insert_commit_data commit_data;
- std::pair<node_ptr, bool> ret =
- (node_algorithms::insert_unique_check
- (this->header_ptr(), key_of_value()(value), this->key_node_comp(this->key_comp()), commit_data));
- return std::pair<iterator, bool>
- ( ret.second ? this->insert_unique_commit(value, commit_data)
- : iterator(ret.first, this->priv_value_traits_ptr())
- , ret.second);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert_unique(const_iterator hint, reference value)
- {
- insert_commit_data commit_data;
- std::pair<node_ptr, bool> ret =
- (node_algorithms::insert_unique_check
- (this->header_ptr(), hint.pointed_node(), key_of_value()(value), this->key_node_comp(this->key_comp()), commit_data));
- return ret.second ? this->insert_unique_commit(value, commit_data)
- : iterator(ret.first, this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Iterator>
- void insert_unique(Iterator b, Iterator e)
- {
- if(this->empty()){
- iterator iend(this->end());
- for (; b != e; ++b)
- this->insert_unique(iend, *b);
- }
- else{
- for (; b != e; ++b)
- this->insert_unique(*b);
- }
- }
- #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
-
-
-
-
-
-
-
-
-
-
-
-
- std::pair<iterator, bool> insert_unique_check(const key_type &key, insert_commit_data &commit_data);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- std::pair<iterator, bool> insert_unique_check(const_iterator hint, const key_type &key, insert_commit_data &commit_data);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator, bool> insert_unique_check
- (const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator, bool> insert_unique_check
- (const_iterator hint, const KeyType &key
- ,KeyTypeKeyCompare comp, insert_commit_data &commit_data);
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) BOOST_NOEXCEPT
- {
- node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
- #if !(defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) ))
-
- iterator p(commit_data.node, this->priv_value_traits_ptr());
- if(!commit_data.link_left){
- ++p;
- }
-
-
- BOOST_ASSERT(( p == this->end() || !this->get_comp()(*p, value) ));
- BOOST_ASSERT(( p == this->begin() || !this->get_comp()(value, *--p) ));
- #endif
- node_algorithms::insert_unique_commit
- (this->header_ptr(), to_insert, commit_data);
- this->sz_traits().increment();
- return iterator(to_insert, this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- iterator insert_before(const_iterator pos, reference value) BOOST_NOEXCEPT
- {
- node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
- this->sz_traits().increment();
- return iterator(node_algorithms::insert_before
- (this->header_ptr(), pos.pointed_node(), to_insert), this->priv_value_traits_ptr());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void push_back(reference value) BOOST_NOEXCEPT
- {
- node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
- this->sz_traits().increment();
- node_algorithms::push_back(this->header_ptr(), to_insert);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void push_front(reference value) BOOST_NOEXCEPT
- {
- node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
- this->sz_traits().increment();
- node_algorithms::push_front(this->header_ptr(), to_insert);
- }
-
-
-
-
-
-
-
-
- iterator erase(const_iterator i) BOOST_NOEXCEPT
- {
- const_iterator ret(i);
- ++ret;
- node_ptr to_erase(i.pointed_node());
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || !node_algorithms::unique(to_erase));
- node_algorithms::erase(this->header_ptr(), to_erase);
- this->sz_traits().decrement();
- BOOST_IF_CONSTEXPR(safemode_or_autounlink)
- node_algorithms::init(to_erase);
- return ret.unconst();
- }
-
-
-
-
-
-
-
-
-
- iterator erase(const_iterator b, const_iterator e) BOOST_NOEXCEPT
- { size_type n; return this->private_erase(b, e, n); }
-
-
-
-
-
-
-
-
-
-
- size_type erase(const key_type &key) BOOST_NOEXCEPT
- { return this->erase(key, this->key_comp()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- BOOST_INTRUSIVE_DOC1ST(size_type
- , typename detail::disable_if_convertible<KeyTypeKeyCompare BOOST_INTRUSIVE_I const_iterator BOOST_INTRUSIVE_I size_type>::type)
- erase(const KeyType& key, KeyTypeKeyCompare comp)
- {
- std::pair<iterator,iterator> p = this->equal_range(key, comp);
- size_type n;
- this->private_erase(p.first, p.second, n);
- return n;
- }
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_and_dispose(const_iterator i, Disposer disposer) BOOST_NOEXCEPT
- {
- node_ptr to_erase(i.pointed_node());
- iterator ret(this->erase(i));
- disposer(this->get_value_traits().to_value_ptr(to_erase));
- return ret;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- size_type erase_and_dispose(const key_type &key, Disposer disposer)
- {
- std::pair<iterator,iterator> p = this->equal_range(key);
- size_type n;
- this->private_erase(p.first, p.second, n, disposer);
- return n;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) BOOST_NOEXCEPT
- { size_type n; return this->private_erase(b, e, n, disposer); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare, class Disposer>
- BOOST_INTRUSIVE_DOC1ST(size_type
- , typename detail::disable_if_convertible<KeyTypeKeyCompare BOOST_INTRUSIVE_I const_iterator BOOST_INTRUSIVE_I size_type>::type)
- erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer)
- {
- std::pair<iterator,iterator> p = this->equal_range(key, comp);
- size_type n;
- this->private_erase(p.first, p.second, n, disposer);
- return n;
- }
-
-
-
-
-
-
-
-
-
- void clear() BOOST_NOEXCEPT
- {
- BOOST_IF_CONSTEXPR(safemode_or_autounlink){
- this->clear_and_dispose(detail::null_disposer());
- }
- else{
- node_algorithms::init_header(this->header_ptr());
- this->sz_traits().set_size(0);
- }
- }
-
-
-
-
-
-
-
-
-
- template<class Disposer>
- void clear_and_dispose(Disposer disposer) BOOST_NOEXCEPT
- {
- node_algorithms::clear_and_dispose(this->header_ptr()
- , detail::node_disposer<Disposer, value_traits, AlgoType>(disposer, &this->get_value_traits()));
- node_algorithms::init_header(this->header_ptr());
- this->sz_traits().set_size(0);
- }
-
-
-
-
-
-
- size_type count(const key_type &key) const
- { return size_type(this->count(key, this->key_comp())); }
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- size_type count(const KeyType &key, KeyTypeKeyCompare comp) const
- {
- std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp);
- size_type n = 0;
- for(; ret.first != ret.second; ++ret.first){ ++n; }
- return n;
- }
- #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
-
-
- size_type count(const key_type &key)
- { return size_type(this->count(key, this->key_comp())); }
- template<class KeyType, class KeyTypeKeyCompare>
- size_type count(const KeyType &key, KeyTypeKeyCompare comp)
- {
- std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp);
- size_type n = 0;
- for(; ret.first != ret.second; ++ret.first){ ++n; }
- return n;
- }
- #else
-
-
-
-
-
-
- iterator lower_bound(const key_type &key);
-
-
-
-
-
-
- const_iterator lower_bound(const key_type &key) const;
-
- template<class KeyType, class KeyTypeKeyCompare>
- iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp);
-
- template<class KeyType, class KeyTypeKeyCompare>
- const_iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp) const;
-
-
-
-
-
-
- iterator upper_bound(const key_type &key);
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp);
-
- const_iterator upper_bound(const key_type &key) const;
-
- template<class KeyType, class KeyTypeKeyCompare>
- const_iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp) const;
-
-
-
-
-
-
- iterator find(const key_type &key);
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- iterator find(const KeyType &key, KeyTypeKeyCompare comp);
-
- const_iterator find(const key_type &key) const;
-
- template<class KeyType, class KeyTypeKeyCompare>
- const_iterator find(const KeyType &key, KeyTypeKeyCompare comp) const;
-
-
-
-
-
-
-
- std::pair<iterator,iterator> equal_range(const key_type &key);
-
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator,iterator> equal_range(const KeyType &key, KeyTypeKeyCompare comp);
-
- std::pair<const_iterator, const_iterator> equal_range(const key_type &key) const;
-
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<const_iterator, const_iterator>
- equal_range(const KeyType &key, KeyTypeKeyCompare comp) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- std::pair<iterator,iterator> bounded_range
- (const key_type &lower_key, const key_type &upper_value, bool left_closed, bool right_closed);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<iterator,iterator> bounded_range
- (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
-
-
- std::pair<const_iterator,const_iterator> bounded_range
- (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
-
- template<class KeyType, class KeyTypeKeyCompare>
- std::pair<const_iterator,const_iterator> bounded_range
- (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
-
-
-
-
-
-
-
-
-
-
-
-
- static iterator s_iterator_to(reference value) BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
-
-
-
-
- static const_iterator s_iterator_to(const_reference value) BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
-
- iterator iterator_to(reference value) BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
-
- const_iterator iterator_to(const_reference value) const BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
-
-
-
- static void init_node(reference value) BOOST_NOEXCEPT;
- #endif
-
-
-
-
-
-
-
-
-
-
- pointer unlink_leftmost_without_rebalance() BOOST_NOEXCEPT
- {
- node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance
- (this->header_ptr()));
- if(!to_be_disposed)
- return 0;
- this->sz_traits().decrement();
- BOOST_IF_CONSTEXPR(safemode_or_autounlink)
- node_algorithms::init(to_be_disposed);
- return this->get_value_traits().to_value_ptr(to_be_disposed);
- }
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void replace_node(iterator replace_this, reference with_this) BOOST_NOEXCEPT;
-
-
-
-
-
- void rebalance() BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
-
- iterator rebalance_subtree(iterator r) BOOST_NOEXCEPT;
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
- static void remove_node(reference value) BOOST_NOEXCEPT
- {
- BOOST_INTRUSIVE_STATIC_ASSERT((!constant_time_size));
- node_ptr to_remove(value_traits::to_node_ptr(value));
- node_algorithms::unlink(to_remove);
- BOOST_IF_CONSTEXPR(safemode_or_autounlink)
- node_algorithms::init(to_remove);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- template<class T, class ...Options2> void merge_unique(bstree<T, Options2...> &);
- #else
- template<class Compare2>
- void merge_unique(bstree_impl
- <ValueTraits, VoidOrKeyOfValue, Compare2, SizeType, ConstantTimeSize, AlgoType, HeaderHolder> &source)
- #endif
- {
- node_ptr it (node_algorithms::begin_node(source.header_ptr()))
- , itend(node_algorithms::end_node (source.header_ptr()));
- while(it != itend){
- node_ptr const p(it);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || !node_algorithms::unique(p));
- it = node_algorithms::next_node(it);
- if( node_algorithms::transfer_unique(this->header_ptr(), this->key_node_comp(this->key_comp()), source.header_ptr(), p) ){
- source.sz_traits().decrement();
- this->sz_traits().increment();
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- template<class T, class ...Options2> void merge_equal(bstree<T, Options2...> &);
- #else
- template<class Compare2>
- void merge_equal(bstree_impl
- <ValueTraits, VoidOrKeyOfValue, Compare2, SizeType, ConstantTimeSize, AlgoType, HeaderHolder> &source)
- #endif
- {
- node_ptr it (node_algorithms::begin_node(source.header_ptr()))
- , itend(node_algorithms::end_node (source.header_ptr()));
- while(it != itend){
- node_ptr const p(it);
- BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || !node_algorithms::unique(p));
- it = node_algorithms::next_node(it);
- node_algorithms::transfer_equal(this->header_ptr(), this->key_node_comp(this->key_comp()), source.header_ptr(), p);
- source.sz_traits().decrement();
- this->sz_traits().increment();
- }
- }
-
-
-
-
-
-
- template <class ExtraChecker>
- void check(ExtraChecker extra_checker) const
- {
- typedef detail::key_nodeptr_comp<key_compare, value_traits, key_of_value> nodeptr_comp_t;
- nodeptr_comp_t nodeptr_comp(this->key_comp(), &this->get_value_traits());
- typedef typename get_node_checker<AlgoType, ValueTraits, nodeptr_comp_t, ExtraChecker>::type node_checker_t;
- typename node_checker_t::return_type checker_return;
- node_algorithms::check(this->header_ptr(), node_checker_t(nodeptr_comp, extra_checker), checker_return);
- BOOST_INTRUSIVE_INVARIANT_ASSERT(!constant_time_size || this->sz_traits().get_size() == checker_return.node_count);
- }
-
-
-
-
-
-
- void check() const
- {
- check(detail::empty_node_checker<ValueTraits>());
- }
- friend bool operator==(const bstree_impl &x, const bstree_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 bstree_impl &x, const bstree_impl &y)
- { return !(x == y); }
- friend bool operator<(const bstree_impl &x, const bstree_impl &y)
- { return ::boost::intrusive::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
- friend bool operator>(const bstree_impl &x, const bstree_impl &y)
- { return y < x; }
- friend bool operator<=(const bstree_impl &x, const bstree_impl &y)
- { return !(x > y); }
- friend bool operator>=(const bstree_impl &x, const bstree_impl &y)
- { return !(x < y); }
- friend void swap(bstree_impl &x, bstree_impl &y)
- { x.swap(y); }
-
- private:
- template<class Disposer>
- iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer)
- {
- for(n = 0; b != e; ++n)
- this->erase_and_dispose(b++, disposer);
- return b.unconst();
- }
- iterator private_erase(const_iterator b, const_iterator e, size_type &n)
- {
- for(n = 0; b != e; ++n)
- this->erase(b++);
- return b.unconst();
- }
-
- };
- #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_bstree
- {
-
- typedef typename pack_options
- < bstree_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 bstree_impl
- < value_traits
- , typename packed_options::key_of_value
- , typename packed_options::compare
- , typename packed_options::size_type
- , packed_options::constant_time_size
- , BsTreeAlgorithms
- , 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 bstree
- : public make_bstree<T,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6
- #else
- Options...
- #endif
- >::type
- {
- typedef typename make_bstree
- <T,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6
- #else
- Options...
- #endif
- >::type Base;
- BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree)
- public:
- typedef typename Base::key_compare key_compare;
- typedef typename Base::value_traits value_traits;
- typedef typename Base::iterator iterator;
- typedef typename Base::const_iterator const_iterator;
-
- BOOST_INTRUSIVE_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
- inline bstree()
- : Base()
- {}
- inline explicit bstree( const key_compare &cmp, const value_traits &v_traits = value_traits())
- : Base(cmp, v_traits)
- {}
- template<class Iterator>
- inline bstree( bool unique, Iterator b, Iterator e
- , const key_compare &cmp = key_compare()
- , const value_traits &v_traits = value_traits())
- : Base(unique, b, e, cmp, v_traits)
- {}
- inline bstree(BOOST_RV_REF(bstree) x)
- : Base(BOOST_MOVE_BASE(Base, x))
- {}
- inline bstree& operator=(BOOST_RV_REF(bstree) x)
- { return static_cast<bstree &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
- template <class Cloner, class Disposer>
- inline void clone_from(const bstree &src, Cloner cloner, Disposer disposer)
- { Base::clone_from(src, cloner, disposer); }
- template <class Cloner, class Disposer>
- inline void clone_from(BOOST_RV_REF(bstree) src, Cloner cloner, Disposer disposer)
- { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
- inline static bstree &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT
- { return static_cast<bstree &>(Base::container_from_end_iterator(end_iterator)); }
- inline static const bstree &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT
- { return static_cast<const bstree &>(Base::container_from_end_iterator(end_iterator)); }
- inline static bstree &container_from_iterator(iterator it) BOOST_NOEXCEPT
- { return static_cast<bstree &>(Base::container_from_iterator(it)); }
- inline static const bstree &container_from_iterator(const_iterator it) BOOST_NOEXCEPT
- { return static_cast<const bstree &>(Base::container_from_iterator(it)); }
- };
- #endif
- }
- }
- #include <boost/intrusive/detail/config_end.hpp>
- #endif
|