1 #ifndef _theplu_yat_utility_weighted_iterator_
2 #define _theplu_yat_utility_weighted_iterator_
25 #include "DataWeight.h"
26 #include "DataWeightProxy.h"
28 #include <boost/iterator/iterator_facade.hpp>
57 template<
typename DataIterator,
typename WeightIterator>
59 :
public boost::iterator_facade<
60 WeightedIterator<DataIterator, WeightIterator>,
62 typename std::iterator_traits<DataIterator>::iterator_category,
63 DataWeightProxy<DataIterator, WeightIterator> >
91 : d_iter_(d), w_iter_(w)
122 template<
typename D2,
typename W2>
124 typename boost::enable_if_convertible<D2,DataIterator>::type* = 0,
125 typename boost::enable_if_convertible<W2,WeightIterator>::type* = 0)
130 friend class boost::iterator_core_access;
135 void advance(
size_t n)
136 { std::advance(d_iter_, n); std::advance(w_iter_, n); }
138 void decrement(
void) { --d_iter_; --w_iter_; }
140 typename std::iterator_traits<DataIterator>::difference_type
142 {
return std::distance(d_iter_, other.d_iter_); }
144 utility::DataWeightProxy<DataIterator, WeightIterator>
145 dereference(
void)
const
146 {
return DataWeightProxy<DataIterator, WeightIterator>(d_iter_,
151 {
return d_iter_==other.d_iter_ && w_iter_==other.w_iter_; }
153 void increment(
void) { ++d_iter_; ++w_iter_; }
164 template<
typename DataIterator,
typename WeightIterator>
165 WeightedIterator<DataIterator, WeightIterator>