diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/multi_index/detail/hash_index_iterator.hpp | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/multi_index/detail/hash_index_iterator.hpp')
-rw-r--r-- | boost/multi_index/detail/hash_index_iterator.hpp | 86 |
1 files changed, 70 insertions, 16 deletions
diff --git a/boost/multi_index/detail/hash_index_iterator.hpp b/boost/multi_index/detail/hash_index_iterator.hpp index 352c1d805a..f8e983dbb4 100644 --- a/boost/multi_index/detail/hash_index_iterator.hpp +++ b/boost/multi_index/detail/hash_index_iterator.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2008 Joaquin M Lopez Munoz. +/* Copyright 2003-2014 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -9,7 +9,7 @@ #ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP #define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_ITERATOR_HPP -#if defined(_MSC_VER)&&(_MSC_VER>=1200) +#if defined(_MSC_VER) #pragma once #endif @@ -19,6 +19,7 @@ #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) #include <boost/serialization/nvp.hpp> #include <boost/serialization/split_member.hpp> +#include <boost/serialization/version.hpp> #endif namespace boost{ @@ -30,10 +31,13 @@ namespace detail{ /* Iterator class for hashed indices. */ -template<typename Node,typename BucketArray> +struct hashed_index_global_iterator_tag{}; +struct hashed_index_local_iterator_tag{}; + +template<typename Node,typename BucketArray,typename Category> class hashed_index_iterator: public forward_iterator_helper< - hashed_index_iterator<Node,BucketArray>, + hashed_index_iterator<Node,BucketArray,Category>, typename Node::value_type, std::ptrdiff_t, const typename Node::value_type*, @@ -41,9 +45,7 @@ class hashed_index_iterator: { public: hashed_index_iterator(){} - hashed_index_iterator(Node* node_,BucketArray* buckets_): - node(node_),buckets(buckets_) - {} + hashed_index_iterator(Node* node_):node(node_){} const typename Node::value_type& operator*()const { @@ -52,7 +54,7 @@ public: hashed_index_iterator& operator++() { - Node::increment(node,buckets->begin(),buckets->end()); + this->increment(Category()); return *this; } @@ -70,16 +72,42 @@ public: { node_base_type* bnode=node; ar<<serialization::make_nvp("pointer",bnode); - ar<<serialization::make_nvp("pointer",buckets); } template<class Archive> - void load(Archive& ar,const unsigned int) + void load(Archive& ar,const unsigned int version) + { + load(ar,version,Category()); + } + + template<class Archive> + void load( + Archive& ar,const unsigned int version,hashed_index_global_iterator_tag) { node_base_type* bnode; ar>>serialization::make_nvp("pointer",bnode); node=static_cast<Node*>(bnode); - ar>>serialization::make_nvp("pointer",buckets); + if(version<1){ + BucketArray* throw_away; /* consume unused ptr */ + ar>>serialization::make_nvp("pointer",throw_away); + } + } + + template<class Archive> + void load( + Archive& ar,const unsigned int version,hashed_index_local_iterator_tag) + { + node_base_type* bnode; + ar>>serialization::make_nvp("pointer",bnode); + node=static_cast<Node*>(bnode); + if(version<1){ + BucketArray* buckets; + ar>>serialization::make_nvp("pointer",buckets); + if(buckets&&node&&node->impl()==buckets->end()->prior()){ + /* end local_iterators used to point to end node, now they are null */ + node=0; + } + } } #endif @@ -90,14 +118,24 @@ public: Node* get_node()const{return node;} private: - Node* node; - BucketArray* buckets; + + void increment(hashed_index_global_iterator_tag) + { + Node::increment(node); + } + + void increment(hashed_index_local_iterator_tag) + { + Node::increment_local(node); + } + + Node* node; }; -template<typename Node,typename BucketArray> +template<typename Node,typename BucketArray,typename Category> bool operator==( - const hashed_index_iterator<Node,BucketArray>& x, - const hashed_index_iterator<Node,BucketArray>& y) + const hashed_index_iterator<Node,BucketArray,Category>& x, + const hashed_index_iterator<Node,BucketArray,Category>& y) { return x.get_node()==y.get_node(); } @@ -106,6 +144,22 @@ bool operator==( } /* namespace multi_index */ +#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) +/* class version = 1 : hashed_index_iterator does no longer serialize a bucket + * array pointer. + */ + +namespace serialization { +template<typename Node,typename BucketArray,typename Category> +struct version< + boost::multi_index::detail::hashed_index_iterator<Node,BucketArray,Category> +> +{ + BOOST_STATIC_CONSTANT(int,value=1); +}; +} /* namespace serialization */ +#endif + } /* namespace boost */ #endif |