Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:39

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_BS_SET_HOOK_HPP
0014 #define BOOST_INTRUSIVE_BS_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/tree_node.hpp>
0020 #include <boost/intrusive/bstree_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 bs_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>
0037 #endif
0038 struct make_bs_set_base_hook
0039 {
0040    /// @cond
0041    typedef typename pack_options
0042    #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0043       < hook_defaults, O1, O2, O3>
0044    #else
0045       < hook_defaults, Options...>
0046    #endif
0047    ::type packed_options;
0048 
0049    typedef generic_hook
0050    < BsTreeAlgorithms
0051    , tree_node_traits<typename packed_options::void_pointer>
0052    , typename packed_options::tag
0053    , packed_options::link_mode
0054    , BsTreeBaseHookId
0055    > implementation_defined;
0056    /// @endcond
0057    typedef implementation_defined type;
0058 };
0059 
0060 //! Derive a class from bs_set_base_hook in order to store objects in
0061 //! in a bs_set/bs_multiset. bs_set_base_hook holds the data necessary to maintain
0062 //! the bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset.
0063 //!
0064 //! The hook admits the following options: \c tag<>, \c void_pointer<>,
0065 //! \c link_mode<>.
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 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0078 template<class ...Options>
0079 #else
0080 template<class O1, class O2, class O3>
0081 #endif
0082 class bs_set_base_hook
0083    :  public make_bs_set_base_hook
0084    #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0085       <O1, O2, O3>
0086    #else
0087       <Options...>
0088    #endif
0089    ::type
0090 
0091 {
0092    #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0093    public:
0094    //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
0095    //!   initializes the node to an unlinked state.
0096    //!
0097    //! <b>Throws</b>: Nothing.
0098    bs_set_base_hook();
0099 
0100    //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
0101    //!   initializes the node to an unlinked state. The argument is ignored.
0102    //!
0103    //! <b>Throws</b>: Nothing.
0104    //!
0105    //! <b>Rationale</b>: Providing a copy-constructor
0106    //!   makes classes using the hook STL-compliant without forcing the
0107    //!   user to do some additional work. \c swap can be used to emulate
0108    //!   move-semantics.
0109    bs_set_base_hook(const bs_set_base_hook& );
0110 
0111    //! <b>Effects</b>: Empty function. The argument is ignored.
0112    //!
0113    //! <b>Throws</b>: Nothing.
0114    //!
0115    //! <b>Rationale</b>: Providing an assignment operator
0116    //!   makes classes using the hook STL-compliant without forcing the
0117    //!   user to do some additional work. \c swap can be used to emulate
0118    //!   move-semantics.
0119    bs_set_base_hook& operator=(const bs_set_base_hook& );
0120 
0121    //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
0122    //!   nothing (ie. no code is generated). If link_mode is \c safe_link and the
0123    //!   object is stored in a set an assertion is raised. If link_mode is
0124    //!   \c auto_unlink and \c is_linked() is true, the node is unlinked.
0125    //!
0126    //! <b>Throws</b>: Nothing.
0127    ~bs_set_base_hook();
0128 
0129    //! <b>Effects</b>: Swapping two nodes swaps the position of the elements
0130    //!   related to those nodes in one or two containers. That is, if the node
0131    //!   this is part of the element e1, the node x is part of the element e2
0132    //!   and both elements are included in the containers s1 and s2, then after
0133    //!   the swap-operation e1 is in s2 at the position of e2 and e2 is in s1
0134    //!   at the position of e1. If one element is not in a container, then
0135    //!   after the swap-operation the other element is not in a container.
0136    //!   Iterators to e1 and e2 related to those nodes are invalidated.
0137    //!
0138    //! <b>Complexity</b>: Constant
0139    //!
0140    //! <b>Throws</b>: Nothing.
0141    void swap_nodes(bs_set_base_hook &other);
0142 
0143    //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
0144    //!
0145    //! <b>Returns</b>: true, if the node belongs to a container, false
0146    //!   otherwise. This function can be used to test whether \c set::iterator_to
0147    //!   will return a valid iterator.
0148    //!
0149    //! <b>Complexity</b>: Constant
0150    bool is_linked() const;
0151 
0152    //! <b>Effects</b>: Removes the node if it's inserted in a container.
0153    //!   This function is only allowed if link_mode is \c auto_unlink.
0154    //!
0155    //! <b>Throws</b>: Nothing.
0156    void unlink();
0157    #endif
0158 };
0159 
0160 //! Helper metafunction to define a \c bs_set_member_hook that yields to the same
0161 //! type when the same options (either explicitly or implicitly) are used.
0162 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0163 template<class ...Options>
0164 #else
0165 template<class O1 = void, class O2 = void, class O3 = void>
0166 #endif
0167 struct make_bs_set_member_hook
0168 {
0169    /// @cond
0170    typedef typename pack_options
0171    #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0172       < hook_defaults, O1, O2, O3>
0173    #else
0174       < hook_defaults, Options...>
0175    #endif
0176 
0177    ::type packed_options;
0178 
0179    typedef generic_hook
0180    < BsTreeAlgorithms
0181    , tree_node_traits<typename packed_options::void_pointer>
0182    , member_tag
0183    , packed_options::link_mode
0184    , NoBaseHookId
0185    > implementation_defined;
0186    /// @endcond
0187    typedef implementation_defined type;
0188 };
0189 
0190 //! Put a public data member bs_set_member_hook in order to store objects of this class in
0191 //! a bs_set/bs_multiset. bs_set_member_hook holds the data necessary for maintaining the
0192 //! bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset.
0193 //!
0194 //! The hook admits the following options: \c void_pointer<>, \c link_mode<>.
0195 //!
0196 //! \c void_pointer<> is the pointer type that will be used internally in the hook
0197 //! and the container configured to use this hook.
0198 //!
0199 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
0200 //! \c auto_unlink or \c safe_link).
0201 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0202 template<class ...Options>
0203 #else
0204 template<class O1, class O2, class O3>
0205 #endif
0206 class bs_set_member_hook
0207    :  public make_bs_set_member_hook
0208       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0209       <O1, O2, O3>
0210       #else
0211       <Options...>
0212       #endif
0213       ::type
0214 {
0215    #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0216    public:
0217    //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
0218    //!   initializes the node to an unlinked state.
0219    //!
0220    //! <b>Throws</b>: Nothing.
0221    bs_set_member_hook();
0222 
0223    //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
0224    //!   initializes the node to an unlinked state. The argument is ignored.
0225    //!
0226    //! <b>Throws</b>: Nothing.
0227    //!
0228    //! <b>Rationale</b>: Providing a copy-constructor
0229    //!   makes classes using the hook STL-compliant without forcing the
0230    //!   user to do some additional work. \c swap can be used to emulate
0231    //!   move-semantics.
0232    bs_set_member_hook(const bs_set_member_hook& );
0233 
0234    //! <b>Effects</b>: Empty function. The argument is ignored.
0235    //!
0236    //! <b>Throws</b>: Nothing.
0237    //!
0238    //! <b>Rationale</b>: Providing an assignment operator
0239    //!   makes classes using the hook STL-compliant without forcing the
0240    //!   user to do some additional work. \c swap can be used to emulate
0241    //!   move-semantics.
0242    bs_set_member_hook& operator=(const bs_set_member_hook& );
0243 
0244    //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
0245    //!   nothing (ie. no code is generated). If link_mode is \c safe_link and the
0246    //!   object is stored in a set an assertion is raised. If link_mode is
0247    //!   \c auto_unlink and \c is_linked() is true, the node is unlinked.
0248    //!
0249    //! <b>Throws</b>: Nothing.
0250    ~bs_set_member_hook();
0251 
0252    //! <b>Effects</b>: Swapping two nodes swaps the position of the elements
0253    //!   related to those nodes in one or two containers. That is, if the node
0254    //!   this is part of the element e1, the node x is part of the element e2
0255    //!   and both elements are included in the containers s1 and s2, then after
0256    //!   the swap-operation e1 is in s2 at the position of e2 and e2 is in s1
0257    //!   at the position of e1. If one element is not in a container, then
0258    //!   after the swap-operation the other element is not in a container.
0259    //!   Iterators to e1 and e2 related to those nodes are invalidated.
0260    //!
0261    //! <b>Complexity</b>: Constant
0262    //!
0263    //! <b>Throws</b>: Nothing.
0264    void swap_nodes(bs_set_member_hook &other);
0265 
0266    //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
0267    //!
0268    //! <b>Returns</b>: true, if the node belongs to a container, false
0269    //!   otherwise. This function can be used to test whether \c set::iterator_to
0270    //!   will return a valid iterator.
0271    //!
0272    //! <b>Complexity</b>: Constant
0273    bool is_linked() const;
0274 
0275    //! <b>Effects</b>: Removes the node if it's inserted in a container.
0276    //!   This function is only allowed if link_mode is \c auto_unlink.
0277    //!
0278    //! <b>Throws</b>: Nothing.
0279    void unlink();
0280    #endif
0281 };
0282 
0283 } //namespace intrusive
0284 } //namespace boost
0285 
0286 #include <boost/intrusive/detail/config_end.hpp>
0287 
0288 #endif //BOOST_INTRUSIVE_BS_SET_HOOK_HPP