Changeset 1083 for trunk/yat/utility


Ignore:
Timestamp:
Feb 13, 2008, 2:13:18 PM (14 years ago)
Author:
Peter
Message:

working on #247

Location:
trunk/yat/utility
Files:
2 edited

Legend:

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

    r1082 r1083  
    4040     @brief Iterator
    4141  */
    42   template<typename Container, typename weighted_tag, typename value,
     42  template<typename Container, typename value,
    4343           typename pointer = value*, typename reference = value&,
    4444           class Policy = IteratorPolicy<Container, reference, value> >
     
    4848  {
    4949  public:
    50     typedef weighted_tag weighted_iterator_type;
     50    typedef typename Policy::weighted_iterator_type weighted_iterator_type;
    5151
    5252  private:
    53     typedef Iterator<Container, weighted_tag, value, pointer, reference,
    54                      Policy> self;
     53    typedef Iterator<Container, value, pointer, reference, Policy> self;
    5554
    5655  public:
  • trunk/yat/utility/IteratorPolicy.h

    r1082 r1083  
    2525*/
    2626
     27#include "iterator_traits.h"
     28
    2729namespace theplu {
    2830namespace yat {
     
    3739    typedef reference data_type;
    3840    typedef weight_t weight_type;
     41    typedef unweighted_type weighted_iterator_type;
    3942
    4043    data_type data(const Container& c, size_t row, size_t column) const
     
    5457   
    5558  };
     59
     60
     61  /**
     62     \brief policy for weighted Iterator
     63  */
     64  template<class Container, typename data_t, typename weight_t>
     65  struct IteratorPolicyWeighted
     66  {
     67    typedef std::pair<data_t, weight_t> reference;
     68    typedef data_t data_type;
     69    typedef weight_t weight_type;
     70    typedef weighted_type weighted_iterator_type;
     71
     72    data_type data(const Container& c, size_t row, size_t column) const
     73    {
     74      return c.data(row, column);
     75    }
     76
     77    reference dereference(const Container& c, size_t row, size_t column) const
     78    {
     79      return reference(this->data(c, row, column),this->weight(c, row, column));
     80    }
     81
     82    weight_type weight(const Container& c, size_t row, size_t column) const
     83    {
     84      return c.weight(row, column);
     85    }
     86   
     87  };
    5688}}} // of namespace utility, yat, and theplu
    5789
Note: See TracChangeset for help on using the changeset viewer.