|
||||
File indexing completed on 2025-01-30 09:44:16
0001 ///////////////////////////////////////////////////////////////////////////// 0002 // 0003 // (C) Copyright Ion Gaztanaga 2007-2013 0004 // 0005 // Distributed under the Boost Software License, Version 1.0. 0006 // (See accompanying file LICENSE_1_0.txt or copy at 0007 // http://www.boost.org/LICENSE_1_0.txt) 0008 // 0009 // See http://www.boost.org/libs/intrusive for documentation. 0010 // 0011 ///////////////////////////////////////////////////////////////////////////// 0012 0013 #ifndef BOOST_INTRUSIVE_AVL_SET_HOOK_HPP 0014 #define BOOST_INTRUSIVE_AVL_SET_HOOK_HPP 0015 0016 #include <boost/intrusive/detail/config_begin.hpp> 0017 #include <boost/intrusive/intrusive_fwd.hpp> 0018 0019 #include <boost/intrusive/detail/avltree_node.hpp> 0020 #include <boost/intrusive/avltree_algorithms.hpp> 0021 #include <boost/intrusive/options.hpp> 0022 #include <boost/intrusive/detail/generic_hook.hpp> 0023 0024 #if defined(BOOST_HAS_PRAGMA_ONCE) 0025 # pragma once 0026 #endif 0027 0028 namespace boost { 0029 namespace intrusive { 0030 0031 //! Helper metafunction to define a \c avl_set_base_hook that yields to the same 0032 //! type when the same options (either explicitly or implicitly) are used. 0033 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0034 template<class ...Options> 0035 #else 0036 template<class O1 = void, class O2 = void, class O3 = void, class O4 = void> 0037 #endif 0038 struct make_avl_set_base_hook 0039 { 0040 /// @cond 0041 typedef typename pack_options 0042 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0043 <hook_defaults, O1, O2, O3, O4> 0044 #else 0045 <hook_defaults, Options...> 0046 #endif 0047 ::type packed_options; 0048 0049 typedef generic_hook 0050 < AvlTreeAlgorithms 0051 , avltree_node_traits<typename packed_options::void_pointer, packed_options::optimize_size> 0052 , typename packed_options::tag 0053 , packed_options::link_mode 0054 , AvlTreeBaseHookId 0055 > implementation_defined; 0056 /// @endcond 0057 typedef implementation_defined type; 0058 }; 0059 0060 //! Derive a class from avl_set_base_hook in order to store objects in 0061 //! in an avl_set/avl_multiset. avl_set_base_hook holds the data necessary to maintain 0062 //! the avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset. 0063 //! 0064 //! The hook admits the following options: \c tag<>, \c void_pointer<>, 0065 //! \c link_mode<> and \c optimize_size<>. 0066 //! 0067 //! \c tag<> defines a tag to identify the node. 0068 //! The same tag value can be used in different classes, but if a class is 0069 //! derived from more than one \c list_base_hook, then each \c list_base_hook needs its 0070 //! unique tag. 0071 //! 0072 //! \c void_pointer<> is the pointer type that will be used internally in the hook 0073 //! and the container configured to use this hook. 0074 //! 0075 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link, 0076 //! \c auto_unlink or \c safe_link). 0077 //! 0078 //! \c optimize_size<> will tell the hook to optimize the hook for size instead 0079 //! of speed. 0080 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0081 template<class ...Options> 0082 #else 0083 template<class O1, class O2, class O3, class O4> 0084 #endif 0085 class avl_set_base_hook 0086 : public make_avl_set_base_hook 0087 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0088 <O1, O2, O3, O4> 0089 #else 0090 <Options...> 0091 #endif 0092 ::type 0093 { 0094 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) 0095 public: 0096 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link 0097 //! initializes the node to an unlinked state. 0098 //! 0099 //! <b>Throws</b>: Nothing. 0100 avl_set_base_hook(); 0101 0102 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link 0103 //! initializes the node to an unlinked state. The argument is ignored. 0104 //! 0105 //! <b>Throws</b>: Nothing. 0106 //! 0107 //! <b>Rationale</b>: Providing a copy-constructor 0108 //! makes classes using the hook STL-compliant without forcing the 0109 //! user to do some additional work. \c swap can be used to emulate 0110 //! move-semantics. 0111 avl_set_base_hook(const avl_set_base_hook& ); 0112 0113 //! <b>Effects</b>: Empty function. The argument is ignored. 0114 //! 0115 //! <b>Throws</b>: Nothing. 0116 //! 0117 //! <b>Rationale</b>: Providing an assignment operator 0118 //! makes classes using the hook STL-compliant without forcing the 0119 //! user to do some additional work. \c swap can be used to emulate 0120 //! move-semantics. 0121 avl_set_base_hook& operator=(const avl_set_base_hook& ); 0122 0123 //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does 0124 //! nothing (ie. no code is generated). If link_mode is \c safe_link and the 0125 //! object is stored in a set an assertion is raised. If link_mode is 0126 //! \c auto_unlink and \c is_linked() is true, the node is unlinked. 0127 //! 0128 //! <b>Throws</b>: Nothing. 0129 ~avl_set_base_hook(); 0130 0131 //! <b>Effects</b>: Swapping two nodes swaps the position of the elements 0132 //! related to those nodes in one or two containers. That is, if the node 0133 //! this is part of the element e1, the node x is part of the element e2 0134 //! and both elements are included in the containers s1 and s2, then after 0135 //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 0136 //! at the position of e1. If one element is not in a container, then 0137 //! after the swap-operation the other element is not in a container. 0138 //! Iterators to e1 and e2 related to those nodes are invalidated. 0139 //! 0140 //! <b>Complexity</b>: Constant 0141 //! 0142 //! <b>Throws</b>: Nothing. 0143 void swap_nodes(avl_set_base_hook &other); 0144 0145 //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. 0146 //! 0147 //! <b>Returns</b>: true, if the node belongs to a container, false 0148 //! otherwise. This function can be used to test whether \c set::iterator_to 0149 //! will return a valid iterator. 0150 //! 0151 //! <b>Complexity</b>: Constant 0152 bool is_linked() const; 0153 0154 //! <b>Effects</b>: Removes the node if it's inserted in a container. 0155 //! This function is only allowed if link_mode is \c auto_unlink. 0156 //! 0157 //! <b>Throws</b>: Nothing. 0158 void unlink(); 0159 #endif 0160 }; 0161 0162 //! Helper metafunction to define a \c avl_set_member_hook that yields to the same 0163 //! type when the same options (either explicitly or implicitly) are used. 0164 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0165 template<class ...Options> 0166 #else 0167 template<class O1 = void, class O2 = void, class O3 = void, class O4 = void> 0168 #endif 0169 struct make_avl_set_member_hook 0170 { 0171 /// @cond 0172 typedef typename pack_options 0173 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0174 <hook_defaults, O1, O2, O3, O4> 0175 #else 0176 <hook_defaults, Options...> 0177 #endif 0178 ::type packed_options; 0179 0180 typedef generic_hook 0181 < AvlTreeAlgorithms 0182 , avltree_node_traits<typename packed_options::void_pointer, packed_options::optimize_size> 0183 , member_tag 0184 , packed_options::link_mode 0185 , NoBaseHookId 0186 > implementation_defined; 0187 /// @endcond 0188 typedef implementation_defined type; 0189 }; 0190 0191 //! Put a public data member avl_set_member_hook in order to store objects of this class in 0192 //! an avl_set/avl_multiset. avl_set_member_hook holds the data necessary for maintaining the 0193 //! avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset. 0194 //! 0195 //! The hook admits the following options: \c void_pointer<>, 0196 //! \c link_mode<> and \c optimize_size<>. 0197 //! 0198 //! \c void_pointer<> is the pointer type that will be used internally in the hook 0199 //! and the container configured to use this hook. 0200 //! 0201 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link, 0202 //! \c auto_unlink or \c safe_link). 0203 //! 0204 //! \c optimize_size<> will tell the hook to optimize the hook for size instead 0205 //! of speed. 0206 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0207 template<class ...Options> 0208 #else 0209 template<class O1, class O2, class O3, class O4> 0210 #endif 0211 class avl_set_member_hook 0212 : public make_avl_set_member_hook 0213 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) 0214 <O1, O2, O3, O4> 0215 #else 0216 <Options...> 0217 #endif 0218 ::type 0219 { 0220 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) 0221 public: 0222 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link 0223 //! initializes the node to an unlinked state. 0224 //! 0225 //! <b>Throws</b>: Nothing. 0226 avl_set_member_hook(); 0227 0228 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link 0229 //! initializes the node to an unlinked state. The argument is ignored. 0230 //! 0231 //! <b>Throws</b>: Nothing. 0232 //! 0233 //! <b>Rationale</b>: Providing a copy-constructor 0234 //! makes classes using the hook STL-compliant without forcing the 0235 //! user to do some additional work. \c swap can be used to emulate 0236 //! move-semantics. 0237 avl_set_member_hook(const avl_set_member_hook& ); 0238 0239 //! <b>Effects</b>: Empty function. The argument is ignored. 0240 //! 0241 //! <b>Throws</b>: Nothing. 0242 //! 0243 //! <b>Rationale</b>: Providing an assignment operator 0244 //! makes classes using the hook STL-compliant without forcing the 0245 //! user to do some additional work. \c swap can be used to emulate 0246 //! move-semantics. 0247 avl_set_member_hook& operator=(const avl_set_member_hook& ); 0248 0249 //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does 0250 //! nothing (ie. no code is generated). If link_mode is \c safe_link and the 0251 //! object is stored in a set an assertion is raised. If link_mode is 0252 //! \c auto_unlink and \c is_linked() is true, the node is unlinked. 0253 //! 0254 //! <b>Throws</b>: Nothing. 0255 ~avl_set_member_hook(); 0256 0257 //! <b>Effects</b>: Swapping two nodes swaps the position of the elements 0258 //! related to those nodes in one or two containers. That is, if the node 0259 //! this is part of the element e1, the node x is part of the element e2 0260 //! and both elements are included in the containers s1 and s2, then after 0261 //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 0262 //! at the position of e1. If one element is not in a container, then 0263 //! after the swap-operation the other element is not in a container. 0264 //! Iterators to e1 and e2 related to those nodes are invalidated. 0265 //! 0266 //! <b>Complexity</b>: Constant 0267 //! 0268 //! <b>Throws</b>: Nothing. 0269 void swap_nodes(avl_set_member_hook &other); 0270 0271 //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink. 0272 //! 0273 //! <b>Returns</b>: true, if the node belongs to a container, false 0274 //! otherwise. This function can be used to test whether \c set::iterator_to 0275 //! will return a valid iterator. 0276 //! 0277 //! <b>Complexity</b>: Constant 0278 bool is_linked() const; 0279 0280 //! <b>Effects</b>: Removes the node if it's inserted in a container. 0281 //! This function is only allowed if link_mode is \c auto_unlink. 0282 //! 0283 //! <b>Throws</b>: Nothing. 0284 void unlink(); 0285 #endif 0286 }; 0287 0288 } //namespace intrusive 0289 } //namespace boost 0290 0291 #include <boost/intrusive/detail/config_end.hpp> 0292 0293 #endif //BOOST_INTRUSIVE_AVL_SET_HOOK_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |