123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- #ifndef BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP
- #define BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP
- #include <boost/intrusive/detail/config_begin.hpp>
- #include <boost/intrusive/intrusive_fwd.hpp>
- #include <boost/intrusive/pointer_traits.hpp>
- #include <boost/intrusive/slist_hook.hpp>
- #include <boost/intrusive/options.hpp>
- #include <boost/intrusive/detail/generic_hook.hpp>
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- namespace boost {
- namespace intrusive {
- template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey>
- struct unordered_node
- : public slist_node<VoidPointer>
- {
- typedef typename pointer_traits
- <VoidPointer>::template rebind_pointer
- < unordered_node<VoidPointer, StoreHash, OptimizeMultiKey> >::type
- node_ptr;
- node_ptr prev_in_group_;
- std::size_t hash_;
- };
- template<class VoidPointer>
- struct unordered_node<VoidPointer, false, true>
- : public slist_node<VoidPointer>
- {
- typedef typename pointer_traits
- <VoidPointer>::template rebind_pointer
- < unordered_node<VoidPointer, false, true> >::type
- node_ptr;
- node_ptr prev_in_group_;
- };
- template<class VoidPointer>
- struct unordered_node<VoidPointer, true, false>
- : public slist_node<VoidPointer>
- {
- typedef typename pointer_traits
- <VoidPointer>::template rebind_pointer
- < unordered_node<VoidPointer, true, false> >::type
- node_ptr;
- std::size_t hash_;
- };
- template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey>
- struct unordered_node_traits
- : public slist_node_traits<VoidPointer>
- {
- typedef slist_node_traits<VoidPointer> reduced_slist_node_traits;
- typedef unordered_node<VoidPointer, StoreHash, OptimizeMultiKey> node;
- typedef typename pointer_traits
- <VoidPointer>::template rebind_pointer
- < node >::type node_ptr;
- typedef typename pointer_traits
- <VoidPointer>::template rebind_pointer
- < const node >::type const_node_ptr;
- static const bool store_hash = StoreHash;
- static const bool optimize_multikey = OptimizeMultiKey;
- inline static node_ptr get_next(const_node_ptr n) BOOST_NOEXCEPT
- { return pointer_traits<node_ptr>::static_cast_from(n->next_); }
- inline static void set_next(node_ptr n, node_ptr next) BOOST_NOEXCEPT
- { n->next_ = next; }
- inline static node_ptr get_prev_in_group(const_node_ptr n) BOOST_NOEXCEPT
- { return n->prev_in_group_; }
- inline static void set_prev_in_group(node_ptr n, node_ptr prev) BOOST_NOEXCEPT
- { n->prev_in_group_ = prev; }
- inline static std::size_t get_hash(const_node_ptr n) BOOST_NOEXCEPT
- { return n->hash_; }
- inline static void set_hash(node_ptr n, std::size_t h) BOOST_NOEXCEPT
- { n->hash_ = h; }
- };
- template<class NodeTraits>
- struct unordered_group_adapter
- {
- typedef typename NodeTraits::node node;
- typedef typename NodeTraits::node_ptr node_ptr;
- typedef typename NodeTraits::const_node_ptr const_node_ptr;
- inline static node_ptr get_next(const_node_ptr n)
- { return NodeTraits::get_prev_in_group(n); }
- inline static void set_next(node_ptr n, node_ptr next)
- { NodeTraits::set_prev_in_group(n, next); }
- };
- template<class NodeTraits>
- struct unordered_algorithms
- : public circular_slist_algorithms<NodeTraits>
- {
- typedef circular_slist_algorithms<NodeTraits> base_type;
- typedef unordered_group_adapter<NodeTraits> group_traits;
- typedef circular_slist_algorithms<group_traits> group_algorithms;
- typedef NodeTraits node_traits;
- typedef typename NodeTraits::node node;
- typedef typename NodeTraits::node_ptr node_ptr;
- typedef typename NodeTraits::const_node_ptr const_node_ptr;
- inline static void init(typename base_type::node_ptr n) BOOST_NOEXCEPT
- {
- base_type::init(n);
- group_algorithms::init(n);
- }
- inline static void init_header(typename base_type::node_ptr n) BOOST_NOEXCEPT
- {
- base_type::init_header(n);
- group_algorithms::init_header(n);
- }
- inline static void unlink(typename base_type::node_ptr n) BOOST_NOEXCEPT
- {
- base_type::unlink(n);
- group_algorithms::unlink(n);
- }
- };
- template<class Algo>
- struct uset_algo_wrapper : public Algo
- {};
- template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey>
- struct get_uset_node_traits
- {
- typedef typename detail::if_c
- < (StoreHash || OptimizeMultiKey)
- , unordered_node_traits<VoidPointer, StoreHash, OptimizeMultiKey>
- , slist_node_traits<VoidPointer>
- >::type type;
- };
- template<bool OptimizeMultiKey>
- struct get_uset_algo_type
- {
- static const algo_types value = OptimizeMultiKey ? UnorderedAlgorithms : UnorderedCircularSlistAlgorithms;
- };
- template<class NodeTraits>
- struct get_algo<UnorderedAlgorithms, NodeTraits>
- {
- typedef unordered_algorithms<NodeTraits> type;
- };
- template<class NodeTraits>
- struct get_algo<UnorderedCircularSlistAlgorithms, NodeTraits>
- {
- typedef uset_algo_wrapper< circular_slist_algorithms<NodeTraits> > type;
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- template<class ...Options>
- #else
- template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
- #endif
- struct make_unordered_set_base_hook
- {
-
- typedef typename pack_options
- < hook_defaults,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4
- #else
- Options...
- #endif
- >::type packed_options;
- typedef generic_hook
- < get_uset_algo_type <packed_options::optimize_multikey>::value
- , typename get_uset_node_traits < typename packed_options::void_pointer
- , packed_options::store_hash
- , packed_options::optimize_multikey
- >::type
- , typename packed_options::tag
- , packed_options::link_mode
- , HashBaseHookId
- > implementation_defined;
-
- typedef implementation_defined type;
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- template<class ...Options>
- #else
- template<class O1, class O2, class O3, class O4>
- #endif
- class unordered_set_base_hook
- : public make_unordered_set_base_hook<
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4
- #else
- Options...
- #endif
- >::type
- {
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- public:
-
-
-
-
- unordered_set_base_hook() BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
-
- unordered_set_base_hook(const unordered_set_base_hook& ) BOOST_NOEXCEPT;
-
-
-
-
-
-
-
-
- unordered_set_base_hook& operator=(const unordered_set_base_hook& ) BOOST_NOEXCEPT;
-
-
-
-
-
-
- ~unordered_set_base_hook();
-
-
-
-
-
-
-
-
-
-
-
-
- void swap_nodes(unordered_set_base_hook &other) BOOST_NOEXCEPT;
-
-
-
-
-
-
-
- bool is_linked() const BOOST_NOEXCEPT;
-
-
-
-
- void unlink() BOOST_NOEXCEPT;
- #endif
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- template<class ...Options>
- #else
- template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
- #endif
- struct make_unordered_set_member_hook
- {
-
- typedef typename pack_options
- < hook_defaults,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4
- #else
- Options...
- #endif
- >::type packed_options;
- typedef generic_hook
- < get_uset_algo_type <packed_options::optimize_multikey>::value
- , typename get_uset_node_traits < typename packed_options::void_pointer
- , packed_options::store_hash
- , packed_options::optimize_multikey
- >::type
- , member_tag
- , packed_options::link_mode
- , NoBaseHookId
- > implementation_defined;
-
- typedef implementation_defined type;
- };
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- template<class ...Options>
- #else
- template<class O1, class O2, class O3, class O4>
- #endif
- class unordered_set_member_hook
- : public make_unordered_set_member_hook<
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4
- #else
- Options...
- #endif
- >::type
- {
- #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
- public:
-
-
-
-
- unordered_set_member_hook();
-
-
-
-
-
-
-
-
-
- unordered_set_member_hook(const unordered_set_member_hook& );
-
-
-
-
-
-
-
-
- unordered_set_member_hook& operator=(const unordered_set_member_hook& );
-
-
-
-
-
-
- ~unordered_set_member_hook();
-
-
-
-
-
-
-
-
-
-
-
-
- void swap_nodes(unordered_set_member_hook &other);
-
-
-
-
-
-
-
- bool is_linked() const;
-
-
-
-
- void unlink();
- #endif
- };
- }
- }
- #include <boost/intrusive/detail/config_end.hpp>
- #endif
|