Ignore:
Timestamp:
Sep 27, 2008, 12:37:33 AM (13 years ago)
Author:
Peter
Message:

refs #368 - redesign to solve some issues regarding mutable functionality in WeightedIterator?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/WeightedIterator.h

    r1532 r1537  
    2323*/
    2424
     25#include <DataWeight.h>
     26#include <DataWeightProxy.h>
     27
    2528#include <boost/iterator/iterator_facade.hpp>
    2629
     
    3235
    3336  /**
    34      @brief WeightedIterator
     37     \brief WeightedIterator
    3538  */
    3639  template<typename DataIterator, typename WeightIterator>
     
    3942    WeightedIterator<DataIterator, WeightIterator>,
    4043    DataWeight,
    41     std::random_access_iterator_tag,
    42     DataWeight>
     44    typename std::iterator_traits<DataIterator>::iterator_category,
     45    DataWeightProxy<DataIterator, WeightIterator> >
    4346   
    4447  {
     
    5053      : d_iter_(d), w_iter_(w)
    5154    {}
     55   
     56
     57    /**
     58       \brief element operator
     59     */
     60    DataWeightProxy<DataIterator, WeightIterator> operator[](int n) const
     61    {
     62      return DataWeightProxy<DataIterator, WeightIterator>(d_iter_+n,
     63                                                           w_iter_+n);
     64    }     
     65   
    5266
    5367    /**
    5468       \brief Conversion constructor.
    55 
     69       
    5670       Create a WeightIterator<Base> from a
    5771       WeightIterator<B2>. Possible if B2 is convertible to a
     
    7286    DataIterator d_iter_;
    7387    WeightIterator w_iter_;
    74 
     88   
    7589    void advance(size_t n)
    7690    { std::advance(d_iter_, n); std::advance(w_iter_, n); }
    7791
    7892    void decrement(void) { --d_iter_; --w_iter_; }
    79 
     93   
    8094    typename std::iterator_traits<DataIterator>::difference_type
    8195    distance_to(const WeightedIterator& other) const
    8296    { return std::distance(d_iter_, other.d_iter_); }
    8397
    84     DataWeight dereference(void) const
    85     { return DataWeight(*d_iter_, *w_iter_); }
     98    utility::DataWeightProxy<DataIterator, WeightIterator>
     99    dereference(void) const
     100    {
     101      return DataWeightProxy<DataIterator, WeightIterator>(d_iter_,
     102                                                           w_iter_);
     103    }
    86104
    87105    bool equal(const WeightedIterator& other) const
Note: See TracChangeset for help on using the changeset viewer.