1 /* Copyright 2003-2007 Joaquín M López Muñoz.
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)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/operators.hpp>
19 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
20 #include <boost/serialization/nvp.hpp>
21 #include <boost/serialization/split_member.hpp>
26 namespace multi_index{
30 /* Iterator class for hashed indices.
33 template<typename Node,typename BucketArray,typename Derived=mpl::na>
34 class hashed_index_iterator:
35 public forward_iterator_helper<
36 hashed_index_iterator<Node,BucketArray,Derived>,
37 typename Node::value_type,
39 const typename Node::value_type*,
40 const typename Node::value_type&>
43 hashed_index_iterator(){}
44 hashed_index_iterator(Node* node_,BucketArray* buckets_):
45 node(node_),buckets(buckets_)
48 const typename Node::value_type& operator*()const
53 hashed_index_iterator& operator++()
55 Node::increment(node,buckets->begin(),buckets->end());
59 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
60 /* Serialization. As for why the following is public,
61 * see explanation in safe_mode_iterator notes in safe_mode.hpp.
64 BOOST_SERIALIZATION_SPLIT_MEMBER()
66 typedef typename Node::base_type node_base_type;
68 template<class Archive>
69 void save(Archive& ar,const unsigned int)const
71 node_base_type* bnode=node;
72 ar<<serialization::make_nvp("pointer",bnode);
73 ar<<serialization::make_nvp("pointer",buckets);
76 template<class Archive>
77 void load(Archive& ar,const unsigned int)
79 node_base_type* bnode;
80 ar>>serialization::make_nvp("pointer",bnode);
81 node=static_cast<Node*>(bnode);
82 ar>>serialization::make_nvp("pointer",buckets);
86 /* get_node is not to be used by the user */
88 typedef Node node_type;
90 Node* get_node()const{return node;}
97 template<typename Node,typename BucketArray,typename Derived>
99 const hashed_index_iterator<Node,BucketArray,Derived>& x,
100 const hashed_index_iterator<Node,BucketArray,Derived>& y)
102 return x.get_node()==y.get_node();
105 } /* namespace multi_index::detail */
107 } /* namespace multi_index */
109 } /* namespace boost */