File indexing completed on 2025-01-18 09:42:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
0010 #define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_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
0030
0031
0032 struct hashed_index_global_iterator_tag{};
0033 struct hashed_index_local_iterator_tag{};
0034
0035 template<
0036 typename Node,typename BucketArray,
0037 typename IndexCategory,typename IteratorCategory
0038 >
0039 class hashed_index_iterator:
0040 public forward_iterator_helper<
0041 hashed_index_iterator<Node,BucketArray,IndexCategory,IteratorCategory>,
0042 typename Node::value_type,
0043 typename Node::difference_type,
0044 const typename Node::value_type*,
0045 const typename Node::value_type&>
0046 {
0047 public:
0048
0049 hashed_index_iterator(){}
0050 hashed_index_iterator(Node* node_):node(node_){}
0051
0052 const typename Node::value_type& operator*()const
0053 {
0054 return node->value();
0055 }
0056
0057 hashed_index_iterator& operator++()
0058 {
0059 this->increment(IteratorCategory());
0060 return *this;
0061 }
0062
0063 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0064
0065
0066
0067
0068 template<class Archive>
0069 void serialize(Archive& ar,const unsigned int version)
0070 {
0071 core::split_member(ar,*this,version);
0072 }
0073
0074 typedef typename Node::base_type node_base_type;
0075
0076 template<class Archive>
0077 void save(Archive& ar,const unsigned int)const
0078 {
0079 node_base_type* bnode=node;
0080 ar<<core::make_nvp("pointer",bnode);
0081 }
0082
0083 template<class Archive>
0084 void load(Archive& ar,const unsigned int version)
0085 {
0086 load(ar,version,IteratorCategory());
0087 }
0088
0089 template<class Archive>
0090 void load(
0091 Archive& ar,const unsigned int version,hashed_index_global_iterator_tag)
0092 {
0093 node_base_type* bnode;
0094 ar>>core::make_nvp("pointer",bnode);
0095 node=static_cast<Node*>(bnode);
0096 if(version<1){
0097 BucketArray* throw_away;
0098 ar>>core::make_nvp("pointer",throw_away);
0099 }
0100 }
0101
0102 template<class Archive>
0103 void load(
0104 Archive& ar,const unsigned int version,hashed_index_local_iterator_tag)
0105 {
0106 node_base_type* bnode;
0107 ar>>core::make_nvp("pointer",bnode);
0108 node=static_cast<Node*>(bnode);
0109 if(version<1){
0110 BucketArray* buckets;
0111 ar>>core::make_nvp("pointer",buckets);
0112 if(buckets&&node&&node->impl()==buckets->end()->prior()){
0113
0114 node=0;
0115 }
0116 }
0117 }
0118 #endif
0119
0120
0121
0122 typedef Node node_type;
0123
0124 Node* get_node()const{return node;}
0125
0126 private:
0127
0128 void increment(hashed_index_global_iterator_tag)
0129 {
0130 Node::template increment<IndexCategory>(node);
0131 }
0132
0133 void increment(hashed_index_local_iterator_tag)
0134 {
0135 Node::template increment_local<IndexCategory>(node);
0136 }
0137
0138 Node* node;
0139 };
0140
0141 template<
0142 typename Node,typename BucketArray,
0143 typename IndexCategory,typename IteratorCategory
0144 >
0145 bool operator==(
0146 const hashed_index_iterator<
0147 Node,BucketArray,IndexCategory,IteratorCategory>& x,
0148 const hashed_index_iterator<
0149 Node,BucketArray,IndexCategory,IteratorCategory>& y)
0150 {
0151 return x.get_node()==y.get_node();
0152 }
0153
0154 }
0155
0156 }
0157
0158 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0159
0160
0161
0162
0163 namespace serialization {
0164 template<
0165 typename Node,typename BucketArray,
0166 typename IndexCategory,typename IteratorCategory
0167 >
0168 struct version<
0169 boost::multi_index::detail::hashed_index_iterator<
0170 Node,BucketArray,IndexCategory,IteratorCategory
0171 >
0172 >
0173 {
0174 BOOST_STATIC_CONSTANT(int,value=1);
0175 };
0176 }
0177 #endif
0178
0179 }
0180
0181 #endif