Changeset 1080 for trunk/yat/utility


Ignore:
Timestamp:
Feb 13, 2008, 12:49:57 PM (14 years ago)
Author:
Peter
Message:

refs #247, #252, and #267

Location:
trunk/yat/utility
Files:
1 added
1 edited

Legend:

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

    r1067 r1080  
    2525*/
    2626
     27#include "IteratorPolicy.h"
    2728#include "yat_assert.h"
    2829
     
    3940     @brief Iterator
    4041  */
    41   template<typename Container, typename T>
     42  template<typename Container, typename weighted_tag, typename value,
     43           typename pointer = value*, typename reference = value&,
     44           class Policy = IteratorPolicy<Container, reference> >
    4245  class Iterator
    43     : public std::iterator<std::random_access_iterator_tag, double, size_t, T,
    44                            void>
     46    : public std::iterator<std::random_access_iterator_tag, value, size_t,
     47                           pointer, reference>
    4548  {
    4649  public:
    47     //typedef size_t difference_type;
    48     typedef T reference;
    49     typedef double* pointer;
    50    
     50    typedef weighted_tag weighted_iterator_type;
     51
    5152  private:
    52     typedef Iterator<Container, T> self;
     53    typedef Iterator<Container, weighted_tag, value, pointer, reference> self;
    5354
    5455  public:
     
    7576      yat_assert<std::out_of_range>(index_ < this->size(),
    7677                                    "Iterator::operator*");
    77       return container_->operator()(this->row(index_), this->column(index_));
     78      return ip_.dereference(*container_, row(index_), column(index_));
    7879    }
    7980
     
    8586      yat_assert<std::out_of_range>(index_+n < this->size(),
    8687                                    "Iterator::operator[]");
    87       return container_->operator()(this->row(index_+n), this->column(index_+n));
     88      return ip_.dereference(*container_, row(index_+n), column(index_+n));
    8889    }
    8990
     
    228229    Container* container_;
    229230    size_t index_;
     231    Policy ip_;
    230232
    231233    size_t column(size_t i) const
     
    236238    { return container_->columns()*container_->rows(); }
    237239
     240
    238241    // Using compiler generated copy
    239242    //Iterator(const Iterator&);
Note: See TracChangeset for help on using the changeset viewer.