Changeset 914 for trunk/yat/statistics


Ignore:
Timestamp:
Sep 29, 2007, 4:18:52 AM (14 years ago)
Author:
Peter
Message:

refactoring add function in Averagers, refs #246

Location:
trunk/yat/statistics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/Averager.h

    r911 r914  
    200200  void add(Averager& a, Iter first, Iter last)
    201201  {
    202     add(a, first, last,
    203         typename utility::weighted_iterator_traits<Iter>::type());
    204   }
    205 
    206   // unweighted impl. (weighted version is not implemented and should
    207   // not compile)
    208   template <typename Iter>
    209   void add(Averager& a, Iter first, Iter last,
    210            utility::unweighted_type type)
    211   {
     202    utility::check_iterator_is_unweighted(first);
    212203    for ( ; first != last; ++first)
    213204      a.add(*first);
    214205  }
    215 
    216206
    217207  // Template implementations
  • trunk/yat/statistics/AveragerPair.h

    r913 r914  
    177177  void add(AveragerPair& ap, Iter1 first1, Iter1 last1, Iter2 first2)
    178178  {
    179     add(ap, first1, last1, first2,
    180         typename utility::weighted_iterator_traits<Iter1>::type(),
    181         typename utility::weighted_iterator_traits<Iter2>::type());
    182   }
    183 
    184   // unweighted impl. (weighted version is not implemented and should
    185   // not compile)
    186   template <typename Iter1, typename Iter2>
    187   void add(AveragerPair& ap, Iter1 first1, Iter1 last1, Iter2 first2,
    188            utility::unweighted_type type1, utility::unweighted_type type2)
    189   {
     179    utility::check_iterator_is_unweighted(first1);
     180    utility::check_iterator_is_unweighted(first2);
    190181    for ( ; first1 != last1; ++first1, ++first2)
    191182      ap.add(*first1, *first2);
  • trunk/yat/statistics/AveragerPairWeighted.h

    r899 r914  
    2828
    2929#include "AveragerWeighted.h"
     30
     31#include "yat/utility/IteratorTraits.h"
    3032
    3133#include <cmath>
     
    176178
    177179  /**
    178      \brief adding a ranges of values to AveragerPairWeighted \a ap
    179   */
     180     \brief adding a ranges of values to AveragerPair \a ap
     181   */
    180182  template <class Iter1, class Iter2>
    181183  void add(AveragerPairWeighted& ap, Iter1 first1, Iter1 last1, Iter2 first2)
    182184  {
    183185    for ( ; first1 != last1; ++first1, ++first2)
    184       ap.add(first1.data(), first2.data(),first1.weight(),first2.weight());
     186      ap.add(utility::iterator_traits_data(first1),
     187             utility::iterator_traits_data(first2),
     188             utility::iterator_traits_weight(first1),
     189             utility::iterator_traits_weight(first2));
    185190  }
    186 
    187 
    188191
    189192
  • trunk/yat/statistics/AveragerWeighted.h

    r910 r914  
    226226  void add(AveragerWeighted& a, Iter first, Iter last)
    227227  {
    228     add(a, first, last,
    229         typename utility::weighted_iterator_traits<Iter>::type());
     228    for ( ; first != last; ++first)
     229      a.add(utility::iterator_traits_data(first));
    230230  }
    231 
    232 
    233   // unweighted impl.
    234   template <typename Iter>
    235   void add(AveragerWeighted& a, Iter first, Iter last,
    236            utility::unweighted_type type)
    237   {
    238     for ( ; first != last; ++first)
    239       a.add(*first);
    240   }
    241 
    242   // weighted impl.
    243   template <typename Iter>
    244   void add(AveragerWeighted& a, Iter first, Iter last,
    245            utility::weighted_type type)
    246   {
    247     for ( ; first != last; ++first)
    248       a.add(first.data(), first.weight());
    249   }
    250 
    251231
    252232  // Template implementations
Note: See TracChangeset for help on using the changeset viewer.