Ignore:
Timestamp:
Sep 23, 2007, 12:05:41 AM (16 years ago)
Author:
Peter
Message:

fixing problems with iterator -> const_iterator conversion

File:
1 edited

Legend:

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

    r881 r883  
    6868    { return index_-rhs.index_; }
    6969
    70     bool equal(const Iterator<return_type, Container>& other) const
    71     { return container_==other.container_ && index_==other.index_; }
    72 
    7370    bool less(const Iterator<return_type, Container>& other) const
    7471    { return index_<other.index_; }
     
    7774    { return Iterator<const double, const Container>(*container_, index_); }
    7875
     76
    7977  private:
    8078    Container* container_;
    8179    size_t index_;
    82 
    8380    // Using compiler generated copy
    8481    //Iterator(const Iterator&);
    8582    //Iterator& operator=(const Iterator&);
     83
     84   
     85  public:
     86    friend bool operator==(const Iterator<return_type, Container>& lhs,
     87                           const Iterator<return_type, Container>& rhs)
     88    { return lhs.container_==rhs.container_ && lhs.index_==rhs.index_; }
     89   
     90    friend bool operator!=(const Iterator<return_type, Container>& lhs,
     91                           const Iterator<return_type, Container>& rhs)
     92    { return !(lhs.container_==rhs.container_ && lhs.index_==rhs.index_); }
     93   
     94    friend bool operator<(const Iterator<return_type, Container>& lhs,
     95                           const Iterator<return_type, Container>& rhs)
     96    { return lhs.index_<rhs.index_; }
     97   
     98    friend bool operator<=(const Iterator<return_type, Container>& lhs,
     99                           const Iterator<return_type, Container>& rhs)
     100    { return lhs.index_<=rhs.index_; }
     101   
     102    friend bool operator>(const Iterator<return_type, Container>& lhs,
     103                           const Iterator<return_type, Container>& rhs)
     104    { return lhs.index_>rhs.index_; }
     105   
     106    friend bool operator>=(const Iterator<return_type, Container>& lhs,
     107                           const Iterator<return_type, Container>& rhs)
     108    { return lhs.index_>=rhs.index_; }
     109   
     110
     111
    86112  };
    87113
     114    /*
    88115  template <typename T1, typename T2>
    89   inline bool operator==(const Iterator<T1,T2>& lhs,
     116  bool operator==(const Iterator<T1,T2>& lhs,
    90117                         const Iterator<T1,T2>& rhs)
    91118  {
     
    94121
    95122  template <typename T1, typename T2>
    96   inline bool operator!=(const Iterator<T1,T2>& lhs,
     123  bool operator!=(const Iterator<T1,T2>& lhs,
    97124                         const Iterator<T1,T2>& rhs)
    98125  {
     
    102129 
    103130  template <typename T1, typename T2>
    104   inline bool operator<(const Iterator<T1,T2>& lhs,
    105                         const Iterator<T1,T2>& rhs)
     131  bool operator<(const Iterator<T1,T2>& lhs,
     132                 const Iterator<T1,T2>& rhs)
    106133  {
    107134    return lhs<rhs;
     
    110137 
    111138  template <typename T1, typename T2>
    112   inline bool operator<=(const Iterator<T1,T2>& lhs,
    113                          const Iterator<T1,T2>& rhs)
     139  bool operator<=(const Iterator<T1,T2>& lhs,
     140                  const Iterator<T1,T2>& rhs)
    114141  {
    115142    return !(rhs<lhs);
     
    118145 
    119146  template <typename T1, typename T2>
    120   inline bool operator>(const Iterator<T1,T2>& lhs,
    121                         const Iterator<T1,T2>& rhs)
     147  bool operator>(const Iterator<T1,T2>& lhs,
     148                 const Iterator<T1,T2>& rhs)
    122149  {
    123150    return rhs<lhs;
     
    126153 
    127154  template <typename T1, typename T2>
    128   inline bool operator>=(const Iterator<T1,T2>& lhs,
    129                          const Iterator<T1,T2>& rhs)
     155  bool operator>=(const Iterator<T1,T2>& lhs,
     156                  const Iterator<T1,T2>& rhs)
    130157  {
    131158    return !(lhs<rhs);
    132159  }
    133 
     160    */
    134161
    135162}}} // of namespace utility, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.