|
||||
File indexing completed on 2025-01-18 09:38:42
0001 ///////////////////////////////////////////////////////////////////////////// 0002 // 0003 // (C) Copyright Ion Gaztanaga 2007-2014 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_OPTIONS_HPP 0014 #define BOOST_INTRUSIVE_OPTIONS_HPP 0015 0016 #include <boost/intrusive/detail/config_begin.hpp> 0017 #include <boost/intrusive/intrusive_fwd.hpp> 0018 #include <boost/intrusive/link_mode.hpp> 0019 #include <boost/intrusive/pack_options.hpp> 0020 0021 #if defined(BOOST_HAS_PRAGMA_ONCE) 0022 # pragma once 0023 #endif 0024 0025 namespace boost { 0026 namespace intrusive { 0027 0028 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED 0029 0030 struct empty 0031 {}; 0032 0033 template<class Functor> 0034 struct fhtraits; 0035 0036 template<class T, class Hook, Hook T::* P> 0037 struct mhtraits; 0038 0039 struct dft_tag; 0040 struct member_tag; 0041 0042 template<class SupposedValueTraits> 0043 struct is_default_hook_tag; 0044 0045 #endif //#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED 0046 0047 //!This option setter specifies if the intrusive 0048 //!container stores its size as a member to 0049 //!obtain constant-time size() member. 0050 BOOST_INTRUSIVE_OPTION_CONSTANT(constant_time_size, bool, Enabled, constant_time_size) 0051 0052 //!This option setter specifies a container header holder type 0053 BOOST_INTRUSIVE_OPTION_TYPE(header_holder_type, HeaderHolder, HeaderHolder, header_holder_type) 0054 0055 //!This option setter specifies the type that 0056 //!the container will use to store its size. 0057 BOOST_INTRUSIVE_OPTION_TYPE(size_type, SizeType, SizeType, size_type) 0058 0059 //!This option setter specifies the strict weak ordering 0060 //!comparison functor for the value type 0061 BOOST_INTRUSIVE_OPTION_TYPE(compare, Compare, Compare, compare) 0062 0063 //!This option setter specifies a function object 0064 //!that specifies the type of the key of an associative 0065 //!container and an operator to obtain it from a value type. 0066 //! 0067 //!This function object must the define a `type` member typedef and 0068 //!a member with signature `type [const&] operator()(const value_type &) const` 0069 //!that will return the key from a value_type of an associative container 0070 BOOST_INTRUSIVE_OPTION_TYPE(key_of_value, KeyOfValue, KeyOfValue, key_of_value) 0071 0072 //!This option setter specifies a function object 0073 //!that specifies the type of the priority of a treap 0074 //!container and an operator to obtain it from a value type. 0075 //! 0076 //!This function object must the define a `type` member typedef and 0077 //!a member with signature `type [const&] operator()(const value_type &) const` 0078 //!that will return the priority from a value_type of a treap container 0079 BOOST_INTRUSIVE_OPTION_TYPE(priority_of_value, PrioOfValue, PrioOfValue, priority_of_value) 0080 0081 //!This option setter for scapegoat containers specifies if 0082 //!the intrusive scapegoat container should use a non-variable 0083 //!alpha value that does not need floating-point operations. 0084 //! 0085 //!If activated, the fixed alpha value is 1/sqrt(2). This 0086 //!option also saves some space in the container since 0087 //!the alpha value and some additional data does not need 0088 //!to be stored in the container. 0089 //! 0090 //!If the user only needs an alpha value near 1/sqrt(2), this 0091 //!option also improves performance since avoids logarithm 0092 //!and division operations when rebalancing the tree. 0093 BOOST_INTRUSIVE_OPTION_CONSTANT(floating_point, bool, Enabled, floating_point) 0094 0095 //!This option setter specifies the equality 0096 //!functor for the value type 0097 BOOST_INTRUSIVE_OPTION_TYPE(equal, Equal, Equal, equal) 0098 0099 //!This option setter specifies the priority comparison 0100 //!functor for the value type 0101 BOOST_INTRUSIVE_OPTION_TYPE(priority, Priority, Priority, priority) 0102 0103 //!This option setter specifies the hash 0104 //!functor for the value type 0105 BOOST_INTRUSIVE_OPTION_TYPE(hash, Hash, Hash, hash) 0106 0107 //!This option setter specifies the relationship between the type 0108 //!to be managed by the container (the value type) and the node to be 0109 //!used in the node algorithms. It also specifies the linking policy. 0110 BOOST_INTRUSIVE_OPTION_TYPE(value_traits, ValueTraits, ValueTraits, proto_value_traits) 0111 0112 //#define BOOST_INTRUSIVE_COMMA , 0113 //#define BOOST_INTRUSIVE_LESS < 0114 //#define BOOST_INTRUSIVE_MORE > 0115 //BOOST_INTRUSIVE_OPTION_TYPE (member_hook, Parent BOOST_INTRUSIVE_COMMA class MemberHook BOOST_INTRUSIVE_COMMA MemberHook Parent::* PtrToMember , mhtraits BOOST_INTRUSIVE_LESS Parent BOOST_INTRUSIVE_COMMA MemberHook BOOST_INTRUSIVE_COMMA PtrToMember BOOST_INTRUSIVE_MORE , proto_value_traits) 0116 //template< class Parent , class MemberHook , MemberHook Parent::* PtrToMember> 0117 //struct member_hook { 0118 // template<class Base> struct pack : Base { 0119 // typedef mhtraits < Parent , MemberHook , PtrToMember > proto_value_traits; 0120 // }; 0121 //}; 0122 // 0123 //#undef BOOST_INTRUSIVE_COMMA 0124 //#undef BOOST_INTRUSIVE_LESS 0125 //#undef BOOST_INTRUSIVE_MORE 0126 0127 //!This option setter specifies the member hook the 0128 //!container must use. 0129 template< typename Parent 0130 , typename MemberHook 0131 , MemberHook Parent::* PtrToMember> 0132 struct member_hook 0133 { 0134 // @cond 0135 // typedef typename MemberHook::hooktags::node_traits node_traits; 0136 // typedef typename node_traits::node node_type; 0137 // typedef node_type Parent::* Ptr2MemNode; 0138 // typedef mhtraits 0139 // < Parent 0140 // , node_traits 0141 // //This cast is really ugly but necessary to reduce template bloat. 0142 // //Since we control the layout between the hook and the node, and there is 0143 // //always single inheritance, the offset of the node is exactly the offset of 0144 // //the hook. Since the node type is shared between all member hooks, this saves 0145 // //quite a lot of symbol stuff. 0146 // , (Ptr2MemNode)PtrToMember 0147 // , MemberHook::hooktags::link_mode> member_value_traits; 0148 typedef mhtraits <Parent, MemberHook, PtrToMember> member_value_traits; 0149 template<class Base> 0150 struct pack : Base 0151 { 0152 typedef member_value_traits proto_value_traits; 0153 }; 0154 /// @endcond 0155 }; 0156 0157 //!This option setter specifies the function object that will 0158 //!be used to convert between values to be inserted in a container 0159 //!and the hook to be used for that purpose. 0160 BOOST_INTRUSIVE_OPTION_TYPE(function_hook, Functor, fhtraits<Functor>, proto_value_traits) 0161 0162 //!This option setter specifies that the container 0163 //!must use the specified base hook 0164 BOOST_INTRUSIVE_OPTION_TYPE(base_hook, BaseHook, BaseHook, proto_value_traits) 0165 0166 //!This option setter specifies the type of 0167 //!a void pointer. This will instruct the hook 0168 //!to use this type of pointer instead of the 0169 //!default one 0170 BOOST_INTRUSIVE_OPTION_TYPE(void_pointer, VoidPointer, VoidPointer, void_pointer) 0171 0172 //!This option setter specifies the type of 0173 //!the tag of a base hook. A type cannot have two 0174 //!base hooks of the same type, so a tag can be used 0175 //!to differentiate two base hooks with otherwise same type 0176 BOOST_INTRUSIVE_OPTION_TYPE(tag, Tag, Tag, tag) 0177 0178 //!This option setter specifies the link mode 0179 //!(normal_link, safe_link or auto_unlink) 0180 BOOST_INTRUSIVE_OPTION_CONSTANT(link_mode, link_mode_type, LinkType, link_mode) 0181 0182 //!This option setter specifies if the hook 0183 //!should be optimized for size instead of for speed. 0184 BOOST_INTRUSIVE_OPTION_CONSTANT(optimize_size, bool, Enabled, optimize_size) 0185 0186 //!This option setter specifies if the slist container should 0187 //!use a linear implementation instead of a circular one. 0188 BOOST_INTRUSIVE_OPTION_CONSTANT(linear, bool, Enabled, linear) 0189 0190 //!If true, slist also stores a pointer to the last element of the singly linked list. 0191 //!This allows O(1) swap and splice_after(iterator, slist &) for circular slists and makes 0192 //!possible new functions like push_back(reference) and back(). 0193 BOOST_INTRUSIVE_OPTION_CONSTANT(cache_last, bool, Enabled, cache_last) 0194 0195 //!This option setter specifies the bucket traits 0196 //!class for unordered associative containers. When this option is specified, 0197 //!instead of using the default bucket traits, a user defined holder will be defined 0198 BOOST_INTRUSIVE_OPTION_TYPE(bucket_traits, BucketTraits, BucketTraits, bucket_traits) 0199 0200 //!This option setter specifies if the unordered hook 0201 //!should offer room to store the hash value. 0202 //!Storing the hash in the hook will speed up rehashing 0203 //!processes in applications where rehashing is frequent, 0204 //!rehashing might throw or the value is heavy to hash. 0205 BOOST_INTRUSIVE_OPTION_CONSTANT(store_hash, bool, Enabled, store_hash) 0206 0207 //!This option setter specifies if the unordered hook 0208 //!should offer room to store another link to another node 0209 //!with the same key. 0210 //!Storing this link will speed up lookups and insertions on 0211 //!unordered_multiset containers with a great number of elements 0212 //!with the same key. 0213 BOOST_INTRUSIVE_OPTION_CONSTANT(optimize_multikey, bool, Enabled, optimize_multikey) 0214 0215 //!This option setter specifies if the length of the bucket array provided by 0216 //!the user will always be power of two. 0217 //!This allows using masks instead of the default modulo operation to determine 0218 //!the bucket number from the hash value, leading to better performance. 0219 //!In debug mode, the provided bucket array length will be checked with assertions. 0220 BOOST_INTRUSIVE_OPTION_CONSTANT(power_2_buckets, bool, Enabled, power_2_buckets) 0221 0222 //!WARNING: this option is EXPERIMENTAL, don't use it in production code 0223 //!This option setter specifies if the length of the bucket array provided by 0224 //!the user will always be a value specified by the 0225 //!suggested_upper|lower_bucket_count call. This allows the use of some 0226 //!precomputed values and speeds hash to bucket index operations, leading 0227 //!to better performance. 0228 //!In debug mode, the provided bucket array length will be checked with assertions. 0229 BOOST_INTRUSIVE_OPTION_CONSTANT(fastmod_buckets, bool, Enabled, fastmod_buckets) 0230 0231 //!This option setter specifies if the container will cache a pointer to the first 0232 //!non-empty bucket so that begin() is always constant-time. 0233 //!This is specially helpful when we can have containers with a few elements 0234 //!but with big bucket arrays (that is, hashtables with low load factors). 0235 BOOST_INTRUSIVE_OPTION_CONSTANT(cache_begin, bool, Enabled, cache_begin) 0236 0237 //!This option setter specifies if the container will compare the hash value 0238 //!before comparing objects. This option can't be specified if store_hash<> 0239 //!is not true. 0240 //!This is specially helpful when we have containers with a high load factor. 0241 //!and the comparison function is much more expensive that comparing already 0242 //!stored hash values. 0243 BOOST_INTRUSIVE_OPTION_CONSTANT(compare_hash, bool, Enabled, compare_hash) 0244 0245 //!This option setter specifies if the hash container will use incremental 0246 //!hashing. With incremental hashing the cost of hash table expansion is spread 0247 //!out across each hash table insertion operation, as opposed to be incurred all at once. 0248 //!Therefore linear hashing is well suited for interactive applications or real-time 0249 //!appplications where the worst-case insertion time of non-incremental hash containers 0250 //!(rehashing the whole bucket array) is not admisible. 0251 BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, incremental) 0252 0253 //!This option setter specifies if the buckets (which form a singly linked lists of nodes) 0254 //!are linear (true) or circular (false, default value). Linear buckets can improve performance 0255 //!in some cases, but the container loses some features like obtaining an iterator from a value. 0256 BOOST_INTRUSIVE_OPTION_CONSTANT(linear_buckets, bool, Enabled, linear_buckets) 0257 0258 /// @cond 0259 0260 struct hook_defaults 0261 { 0262 typedef void* void_pointer; 0263 static const link_mode_type link_mode = safe_link; 0264 typedef dft_tag tag; 0265 static const bool optimize_size = false; 0266 static const bool store_hash = false; 0267 static const bool linear = false; 0268 static const bool optimize_multikey = false; 0269 }; 0270 0271 /// @endcond 0272 0273 } //namespace intrusive { 0274 } //namespace boost { 0275 0276 #include <boost/intrusive/detail/config_end.hpp> 0277 0278 #endif //#ifndef BOOST_INTRUSIVE_OPTIONS_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |