Changeset 910 for trunk/yat/statistics


Ignore:
Timestamp:
Sep 29, 2007, 2:20:10 AM (16 years ago)
Author:
Peter
Message:

impl add function for AveragerWeighted?. The function distinguishes between normal iterators and weighted iterators, and call the member add function appropriately. refs #246

Location:
trunk/yat/statistics
Files:
2 edited

Legend:

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

    r887 r910  
    195195     \brief adding a ranges of values to Averager \a a
    196196   */
    197   template <class Aver, typename Iter>
    198   void add(Aver& a, Iter first, Iter last)
     197  template <typename Iter>
     198  void add(Averager& a, Iter first, Iter last)
    199199  {
    200200    for ( ; first != last; ++first)
  • trunk/yat/statistics/AveragerWeighted.h

    r888 r910  
    2828
    2929#include "Averager.h"
     30#include "yat/utility/IteratorTraits.h"
    3031
    3132#include <cmath>
     
    219220  };
    220221
     222  /**
     223     \brief adding a ranges of values to Averager \a a
     224   */
     225  template <typename Iter>
     226  void add(AveragerWeighted& a, Iter first, Iter last)
     227  {
     228    add(a, first, last,
     229        typename utility::weighted_iterator_traits<Iter>::type());
     230  }
     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
     251
    221252  // Template implementations
    222253  template <typename T1, typename T2>
Note: See TracChangeset for help on using the changeset viewer.