Ignore:
Timestamp:
Feb 14, 2008, 3:26:19 PM (13 years ago)
Author:
Peter
Message:

Closes #247. Removed IteratorWeighted? iterators over weighted container instead can use Iterator with a special Policy.

File:
1 edited

Legend:

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

    r1041 r1088  
    120120
    121121  /**
    122     Function to be used to make compile-time decision how to return
    123     data from an iterator separating two cases: weighted and
    124     unweighted.
     122     \brief traits to make unweighted iterator work in as a weighted
    125123
    126     In this way unweighted iterators can be used in a weighted context.
     124     This class must be implemented for every iterator that can be weighted.
     125
     126     \see StrideIterator and Iterator
    127127   */
    128   // Peter, perhaps these should be templatized, but for now return
    129   // type double is hard coded.
    130128  template <class Iter>
    131   double iterator_traits_data(Iter iter)
    132   { return iterator_traits_data(iter, typename
    133                                 weighted_iterator_traits<Iter>::type()); }
     129  struct iterator_traits {
     130    // Peter, perhaps these should be templatized, but for now return
     131    // type double is hard coded.
     132    /**
     133       \return data that is *iter
     134    */
     135    double data(Iter iter) const
     136    { check_iterator_is_unweighted(iter); return *iter; }
    134137
    135   /**
    136      \return data for weighted iterator
    137    */
    138   template <class Iter>
    139   double iterator_traits_data(Iter i, weighted_type)
    140   { return i.data(); }
     138    /**
     139       \return 1.0
     140    */
     141    double weight(Iter iter) const
     142    { check_iterator_is_unweighted(iter); return 1.0; }
    141143
    142   /**
    143      \return data for unweighted data
    144    */
    145   template <class Iter>
    146   double iterator_traits_data(Iter i, unweighted_type)
    147   { return *i; }
    148 
    149   /**
    150     Function to be used to make compile-time decision how to return
    151     data from an iterator separating two cases: weighted and
    152     unweighted.
    153 
    154     In this way unweighted iterators can be used in a weighted context
    155     and weight will be set to unity.
    156    */
    157   // Peter, perhaps these should be templatized, but for now return
    158   // type double is hard coded.
    159   template <class Iter>
    160   double iterator_traits_weight(Iter iter)
    161   { return iterator_traits_weight(iter, typename
    162                                   weighted_iterator_traits<Iter>::type()); }
    163 
    164   /**
    165      \return weight for weighted iterator
    166    */
    167   template <class Iter>
    168   double iterator_traits_weight(Iter i, weighted_type)
    169   { return i.weight(); }
    170 
    171   /**
    172      \return weight for unweighted iterator
    173    */
    174   template <class Iter>
    175   double iterator_traits_weight(Iter i, unweighted_type)
    176   { return 1.0; }
    177 
     144  };
    178145
    179146}}} // of namespace utility, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.