Ignore:
Timestamp:
Jul 17, 2008, 4:32:16 PM (13 years ago)
Author:
Peter
Message:

fixing problems with MatrixWeighted? iterators

File:
1 edited

Legend:

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

    r1373 r1382  
    2626*/
    2727
     28#include "DataWeight.h"
     29
    2830#include <iterator>
     31#include <vector>
    2932
    3033namespace theplu {
     
    6063    typedef unweighted_iterator_tag type;
    6164  };
     65
     66  /**
     67     Specialization for std::vector<DataWeight>::iterator
     68   */
     69  template<>
     70  struct weighted_iterator_traits<std::vector<DataWeight>::iterator> {
     71    /**
     72       iterator to vector<DataWeight> is weighted
     73    */
     74    typedef weighted_iterator_tag type;
     75  };
     76
     77
     78  /**
     79     Specialization for std::vector<DataWeight>::const_iterator
     80   */
     81  template<>
     82  struct weighted_iterator_traits<std::vector<DataWeight>::const_iterator> {
     83    /**
     84       const_iterator to vector<DataWeight> is weighted
     85    */
     86    typedef weighted_iterator_tag type;
     87  };
     88
    6289
    6390  /**
     
    175202  };
    176203
     204
     205  /**
     206     Specialization for std::vector<DataWeight>::iterator
     207   */
     208  template <>
     209  struct iterator_traits<std::vector<DataWeight>::iterator> {
     210    /**
     211       mutable iterator
     212     */
     213    typedef double& data_reference;
     214
     215    /**
     216       mutable iterator
     217     */
     218    typedef double& weight_reference;
     219
     220    /**
     221       \return data using DataWeight::data()
     222    */
     223    data_reference data(std::vector<DataWeight>::iterator iter) const
     224    { return iter->data(); }
     225
     226    /**
     227       \return weight using DataWeight::weight()
     228    */
     229    weight_reference weight(std::vector<DataWeight>::iterator iter) const
     230    { return iter->weight(); }
     231
     232  };
     233
     234
     235  /**
     236     Specialization for std::vector<DataWeight>::const_iterator
     237   */
     238  template <>
     239  struct iterator_traits<std::vector<DataWeight>::const_iterator> {
     240    /**
     241       const iterator
     242     */
     243    typedef const double& data_reference;
     244
     245    /**
     246       const iterator
     247     */
     248    typedef const double& weight_reference;
     249
     250    /**
     251       \return data using DataWeight::data()
     252    */
     253    data_reference data(std::vector<DataWeight>::iterator iter) const
     254    { return iter->data(); }
     255
     256    /**
     257       \return weight using DataWeight::weight()
     258    */
     259    weight_reference weight(std::vector<DataWeight>::iterator iter) const
     260    { return iter->weight(); }
     261
     262  };
     263
    177264}}} // of namespace utility, yat, and theplu
    178265
Note: See TracChangeset for help on using the changeset viewer.