Back to home page

EIC code displayed by LXR

 
 

    


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

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_SLIST_HOOK_HPP
0015 #define BOOST_INTRUSIVE_SLIST_HOOK_HPP
0016 
0017 #include <boost/intrusive/detail/config_begin.hpp>
0018 #include <boost/intrusive/intrusive_fwd.hpp>
0019 
0020 #include <boost/intrusive/detail/slist_node.hpp>
0021 #include <boost/intrusive/circular_slist_algorithms.hpp>
0022 #include <boost/intrusive/link_mode.hpp>
0023 #include <boost/intrusive/options.hpp>
0024 #include <boost/intrusive/detail/generic_hook.hpp>
0025 
0026 #if defined(BOOST_HAS_PRAGMA_ONCE)
0027 #  pragma once
0028 #endif
0029 
0030 namespace boost {
0031 namespace intrusive {
0032 
0033 //! Helper metafunction to define a \c slist_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_slist_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    < CircularSListAlgorithms
0054    , slist_node_traits<typename packed_options::void_pointer>
0055    , typename packed_options::tag
0056    , packed_options::link_mode
0057    , SlistBaseHookId
0058    > implementation_defined;
0059    /// @endcond
0060    typedef implementation_defined type;
0061 };
0062 
0063 //! Derive a class from slist_base_hook in order to store objects in
0064 //! in an list. slist_base_hook holds the data necessary to maintain the
0065 //! list and provides an appropriate value_traits class for list.
0066 //!
0067 //! The hook admits the following options: \c tag<>, \c void_pointer<> and
0068 //! \c link_mode<>.
0069 //!
0070 //! \c tag<> defines a tag to identify the node.
0071 //! The same tag value can be used in different classes, but if a class is
0072 //! derived from more than one \c list_base_hook, then each \c list_base_hook needs its
0073 //! unique tag.
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 void_pointer<> is the pointer type that will be used internally in the hook
0079 //! and the container configured to use this hook.
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>
0084 #endif
0085 class slist_base_hook
0086    :  public make_slist_base_hook<
0087          #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0088          O1, O2, O3
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    slist_base_hook() BOOST_NOEXCEPT;
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    slist_base_hook(const slist_base_hook& ) BOOST_NOEXCEPT;
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    slist_base_hook& operator=(const slist_base_hook& ) BOOST_NOEXCEPT;
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 an slist 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    ~slist_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(slist_base_hook &other) BOOST_NOEXCEPT;
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 slist::iterator_to
0149    //!   will return a valid iterator.
0150    //!
0151    //! <b>Throws</b>: Nothing.
0152    //!
0153    //! <b>Complexity</b>: Constant
0154    bool is_linked() const BOOST_NOEXCEPT;
0155 
0156    //! <b>Effects</b>: Removes the node if it's inserted in a container.
0157    //!   This function is only allowed if link_mode is \c auto_unlink.
0158    //!
0159    //! <b>Throws</b>: Nothing.
0160    void unlink() BOOST_NOEXCEPT;
0161    #endif
0162 };
0163 
0164 //! Helper metafunction to define a \c slist_member_hook that yields to the same
0165 //! type when the same options (either explicitly or implicitly) are used.
0166 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0167 template<class ...Options>
0168 #else
0169 template<class O1 = void, class O2 = void, class O3 = void>
0170 #endif
0171 struct make_slist_member_hook
0172 {
0173    /// @cond
0174    typedef typename pack_options
0175       < hook_defaults,
0176          #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0177          O1, O2, O3
0178          #else
0179          Options...
0180          #endif
0181       >::type packed_options;
0182 
0183    typedef generic_hook
0184    < CircularSListAlgorithms
0185    , slist_node_traits<typename packed_options::void_pointer>
0186    , member_tag
0187    , packed_options::link_mode
0188    , NoBaseHookId
0189    > implementation_defined;
0190    /// @endcond
0191    typedef implementation_defined type;
0192 };
0193 
0194 //! Put a public data member slist_member_hook in order to store objects of this class in
0195 //! an list. slist_member_hook holds the data necessary for maintaining the list and
0196 //! provides an appropriate value_traits class for list.
0197 //!
0198 //! The hook admits the following options: \c void_pointer<> and
0199 //! \c link_mode<>.
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 void_pointer<> is the pointer type that will be used internally in the hook
0205 //! and the container configured to use this hook.
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>
0210 #endif
0211 class slist_member_hook
0212    :  public make_slist_member_hook<
0213          #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0214          O1, O2, O3
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    slist_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    slist_member_hook(const slist_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    slist_member_hook& operator=(const slist_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 an slist 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    ~slist_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(slist_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 slist::iterator_to
0275    //!   will return a valid iterator.
0276    //!
0277    //! <b>Note</b>: If this member is called when the value is inserted in a
0278    //!   slist with the option linear<true>, this function will return "false"
0279    //!   for the last element, as it is not linked to anything (the next element is null),
0280    //!   so use with care.
0281    //!  
0282    //! <b>Complexity</b>: Constant
0283    bool is_linked() const;
0284 
0285    //! <b>Effects</b>: Removes the node if it's inserted in a container.
0286    //!   This function is only allowed if link_mode is \c auto_unlink.
0287    //!
0288    //! <b>Throws</b>: Nothing.
0289    void unlink();
0290    #endif
0291 };
0292 
0293 } //namespace intrusive
0294 } //namespace boost
0295 
0296 #include <boost/intrusive/detail/config_end.hpp>
0297 
0298 #endif //BOOST_INTRUSIVE_SLIST_HOOK_HPP