Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:06

0001 /* Copyright 2003-2023 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/multi_index for library home page.
0007  */
0008 
0009 #ifndef BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
0010 #define BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
0017 #include <boost/operators.hpp>
0018 
0019 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0020 #include <boost/core/serialization.hpp>
0021 #endif
0022 
0023 namespace boost{
0024 
0025 namespace multi_index{
0026 
0027 namespace detail{
0028 
0029 /* Iterator class for node-based indices with bidirectional
0030  * iterators (ordered and sequenced indices.)
0031  */
0032 
0033 template<typename Node>
0034 class bidir_node_iterator:
0035   public bidirectional_iterator_helper<
0036     bidir_node_iterator<Node>,
0037     typename Node::value_type,
0038     typename Node::difference_type,
0039     const typename Node::value_type*,
0040     const typename Node::value_type&>
0041 {
0042 public:
0043   /* coverity[uninit_ctor]: suppress warning */
0044   bidir_node_iterator(){}
0045   explicit bidir_node_iterator(Node* node_):node(node_){}
0046 
0047   const typename Node::value_type& operator*()const
0048   {
0049     return node->value();
0050   }
0051 
0052   bidir_node_iterator& operator++()
0053   {
0054     Node::increment(node);
0055     return *this;
0056   }
0057 
0058   bidir_node_iterator& operator--()
0059   {
0060     Node::decrement(node);
0061     return *this;
0062   }
0063 
0064 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0065   /* Serialization. As for why the following is public,
0066    * see explanation in safe_mode_iterator notes in safe_mode.hpp.
0067    */
0068 
0069   template<class Archive>
0070   void serialize(Archive& ar,const unsigned int version)
0071   {
0072     core::split_member(ar,*this,version);
0073   }
0074 
0075   typedef typename Node::base_type node_base_type;
0076 
0077   template<class Archive>
0078   void save(Archive& ar,const unsigned int)const
0079   {
0080     node_base_type* bnode=node;
0081     ar<<core::make_nvp("pointer",bnode);
0082   }
0083 
0084   template<class Archive>
0085   void load(Archive& ar,const unsigned int)
0086   {
0087     node_base_type* bnode;
0088     ar>>core::make_nvp("pointer",bnode);
0089     node=static_cast<Node*>(bnode);
0090   }
0091 #endif
0092 
0093   /* get_node is not to be used by the user */
0094 
0095   typedef Node node_type;
0096 
0097   Node* get_node()const{return node;}
0098 
0099 private:
0100   Node* node;
0101 };
0102 
0103 template<typename Node>
0104 bool operator==(
0105   const bidir_node_iterator<Node>& x,
0106   const bidir_node_iterator<Node>& y)
0107 {
0108   return x.get_node()==y.get_node();
0109 }
0110 
0111 } /* namespace multi_index::detail */
0112 
0113 } /* namespace multi_index */
0114 
0115 } /* namespace boost */
0116 
0117 #endif