]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/multi_index/detail/hash_index_iterator.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / multi_index / detail / hash_index_iterator.hpp
CommitLineData
20effc67 1/* Copyright 2003-2020 Joaquin M Lopez Munoz.
7c673cae
FG
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 *
6 * See http://www.boost.org/libs/multi_index for library home page.
7 */
8
9#ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
10#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
11
12#if defined(_MSC_VER)
13#pragma once
14#endif
15
16#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17#include <boost/operators.hpp>
18
19#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
20#include <boost/serialization/nvp.hpp>
21#include <boost/serialization/split_member.hpp>
22#include <boost/serialization/version.hpp>
23#endif
24
25namespace boost{
26
27namespace multi_index{
28
29namespace detail{
30
31/* Iterator class for hashed indices.
32 */
33
34struct hashed_index_global_iterator_tag{};
35struct hashed_index_local_iterator_tag{};
36
20effc67
TL
37template<
38 typename Node,typename BucketArray,
39 typename IndexCategory,typename IteratorCategory
40>
7c673cae
FG
41class hashed_index_iterator:
42 public forward_iterator_helper<
20effc67 43 hashed_index_iterator<Node,BucketArray,IndexCategory,IteratorCategory>,
7c673cae 44 typename Node::value_type,
92f5a8d4 45 typename Node::difference_type,
7c673cae
FG
46 const typename Node::value_type*,
47 const typename Node::value_type&>
48{
49public:
50 /* coverity[uninit_ctor]: suppress warning */
51 hashed_index_iterator(){}
52 hashed_index_iterator(Node* node_):node(node_){}
53
54 const typename Node::value_type& operator*()const
55 {
56 return node->value();
57 }
58
59 hashed_index_iterator& operator++()
60 {
20effc67 61 this->increment(IteratorCategory());
7c673cae
FG
62 return *this;
63 }
64
65#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
66 /* Serialization. As for why the following is public,
67 * see explanation in safe_mode_iterator notes in safe_mode.hpp.
68 */
69
70 BOOST_SERIALIZATION_SPLIT_MEMBER()
71
72 typedef typename Node::base_type node_base_type;
73
74 template<class Archive>
75 void save(Archive& ar,const unsigned int)const
76 {
77 node_base_type* bnode=node;
78 ar<<serialization::make_nvp("pointer",bnode);
79 }
80
81 template<class Archive>
82 void load(Archive& ar,const unsigned int version)
83 {
20effc67 84 load(ar,version,IteratorCategory());
7c673cae
FG
85 }
86
87 template<class Archive>
88 void load(
89 Archive& ar,const unsigned int version,hashed_index_global_iterator_tag)
90 {
91 node_base_type* bnode;
92 ar>>serialization::make_nvp("pointer",bnode);
93 node=static_cast<Node*>(bnode);
94 if(version<1){
95 BucketArray* throw_away; /* consume unused ptr */
96 ar>>serialization::make_nvp("pointer",throw_away);
97 }
98 }
99
100 template<class Archive>
101 void load(
102 Archive& ar,const unsigned int version,hashed_index_local_iterator_tag)
103 {
104 node_base_type* bnode;
105 ar>>serialization::make_nvp("pointer",bnode);
106 node=static_cast<Node*>(bnode);
107 if(version<1){
108 BucketArray* buckets;
109 ar>>serialization::make_nvp("pointer",buckets);
110 if(buckets&&node&&node->impl()==buckets->end()->prior()){
111 /* end local_iterators used to point to end node, now they are null */
112 node=0;
113 }
114 }
115 }
116#endif
117
118 /* get_node is not to be used by the user */
119
120 typedef Node node_type;
121
122 Node* get_node()const{return node;}
123
124private:
125
126 void increment(hashed_index_global_iterator_tag)
127 {
20effc67 128 Node::template increment<IndexCategory>(node);
7c673cae
FG
129 }
130
131 void increment(hashed_index_local_iterator_tag)
132 {
20effc67 133 Node::template increment_local<IndexCategory>(node);
7c673cae
FG
134 }
135
136 Node* node;
137};
138
20effc67
TL
139template<
140 typename Node,typename BucketArray,
141 typename IndexCategory,typename IteratorCategory
142>
7c673cae 143bool operator==(
20effc67
TL
144 const hashed_index_iterator<
145 Node,BucketArray,IndexCategory,IteratorCategory>& x,
146 const hashed_index_iterator<
147 Node,BucketArray,IndexCategory,IteratorCategory>& y)
7c673cae
FG
148{
149 return x.get_node()==y.get_node();
150}
151
152} /* namespace multi_index::detail */
153
154} /* namespace multi_index */
155
156#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
157/* class version = 1 : hashed_index_iterator does no longer serialize a bucket
158 * array pointer.
159 */
160
161namespace serialization {
20effc67
TL
162template<
163 typename Node,typename BucketArray,
164 typename IndexCategory,typename IteratorCategory
165>
7c673cae 166struct version<
20effc67
TL
167 boost::multi_index::detail::hashed_index_iterator<
168 Node,BucketArray,IndexCategory,IteratorCategory
169 >
7c673cae
FG
170>
171{
172 BOOST_STATIC_CONSTANT(int,value=1);
173};
174} /* namespace serialization */
175#endif
176
177} /* namespace boost */
178
179#endif