Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:53:51

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