Changeset 1082 for trunk/yat


Ignore:
Timestamp:
Feb 13, 2008, 1:50:45 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

    r1080 r1082  
    4242  template<typename Container, typename weighted_tag, typename value,
    4343           typename pointer = value*, typename reference = value&,
    44            class Policy = IteratorPolicy<Container, reference> >
     44           class Policy = IteratorPolicy<Container, reference, value> >
    4545  class Iterator
    4646    : public std::iterator<std::random_access_iterator_tag, value, size_t,
     
    5151
    5252  private:
    53     typedef Iterator<Container, weighted_tag, value, pointer, reference> self;
     53    typedef Iterator<Container, weighted_tag, value, pointer, reference,
     54                     Policy> self;
    5455
    5556  public:
     
    6869    Iterator(Container& container, size_t row, size_t column)
    6970      : container_(&container), index_(row*container.columns()+column) {}
     71
     72    /**
     73       \return data
     74    */
     75    typename Policy::data_type data(void) const
     76    { yat_assert<std::out_of_range>(index_<this->size(),
     77                                    "Iterator::data");
     78      return ip_.data(*container_, row(index_), column(index_));
     79    }
     80
     81    /**
     82       \return weight
     83    */
     84    typename Policy::weight_type weight(void) const
     85    { yat_assert<std::out_of_range>(index_<this->size(),
     86                                    "Iterator::weight");
     87      return ip_.weight(*container_, row(index_), column(index_));
     88    }
    7089
    7190    /**
  • trunk/yat/utility/IteratorPolicy.h

    r1080 r1082  
    3232     \brief Default policy for Iterator
    3333  */
    34   template<class Container, typename reference>
     34  template<class Container, typename reference, typename weight_t>
    3535  struct IteratorPolicy
    3636  {
     37    typedef reference data_type;
     38    typedef weight_t weight_type;
     39
     40    data_type data(const Container& c, size_t row, size_t column) const
     41    {
     42      return c(row, column);
     43    }
     44
    3745    reference dereference(const Container& c, size_t row, size_t column) const
    3846    {
    3947      return c(row, column);
    4048    }
     49
     50    weight_type weight(const Container& c, size_t row, size_t column) const
     51    {
     52      return 1.0;
     53    }
     54   
    4155  };
    4256}}} // of namespace utility, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.