Changeset 881
- Timestamp:
- Sep 22, 2007, 10:22:36 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/iterator_test.cc
r880 r881 49 49 classifier::DataLookup1D lookup(vec); 50 50 utility::vector::iterator begin=vec.begin(); 51 // test iterator to const_iterator conversion 52 utility::vector::const_iterator ci = vec.begin(); 53 ci = begin; 54 //if (begin!=ci) 55 //ok = false; 56 51 57 utility::vector::iterator end=vec.end(); 52 58 std::sort(begin, end); -
trunk/yat/classifier/DataLookup1D.h
r880 r881 51 51 public: 52 52 53 typedef utility:: constIterator<const classifier::DataLookup1D>53 typedef utility::Iterator<const double, const classifier::DataLookup1D> 54 54 const_iterator; 55 55 -
trunk/yat/utility/Iterator.h
r880 r881 35 35 @brief Iterator 36 36 */ 37 template<typename Container>37 template<typename return_type, typename Container> 38 38 class Iterator 39 39 { … … 52 52 : container_(&container), index_(index) {} 53 53 54 re ference operator*(void) const { return container_->operator()(index_); }54 return_type operator*(void) const { return container_->operator()(index_); } 55 55 const Iterator& operator++(void) { ++index_; return *this; } 56 56 Iterator operator++(int) 57 { Iterator< Container> tmp(*this); ++index_; return tmp;}57 { Iterator<return_type, Container> tmp(*this); ++index_; return tmp;} 58 58 Iterator& operator+=(int n) { index_+=n; return *this; } 59 59 Iterator operator+(int n) 60 { return Iterator< Container>(*container_, index_+n); }60 { return Iterator<return_type, Container>(*container_, index_+n); } 61 61 Iterator operator--(int) 62 { Iterator< Container> tmp(*this); --index_; return tmp;}62 { Iterator<return_type, Container> tmp(*this); --index_; return tmp;} 63 63 Iterator operator--(void) { --index_; return *this; } 64 64 Iterator& operator-=(int n) { index_-=n; return *this; } 65 65 Iterator operator-(size_t n) 66 { return Iterator< Container>(*container_, index_-n); }66 { return Iterator<return_type, Container>(*container_, index_-n); } 67 67 size_t operator-(const Iterator& rhs) 68 68 { return index_-rhs.index_; } 69 69 70 bool equal(const Iterator< Container>& other) const70 bool equal(const Iterator<return_type, Container>& other) const 71 71 { return container_==other.container_ && index_==other.index_; } 72 72 73 bool less(const Iterator< Container>& other) const73 bool less(const Iterator<return_type, Container>& other) const 74 74 { return index_<other.index_; } 75 76 operator Iterator<const double, const Container> () 77 { return Iterator<const double, const Container>(*container_, index_); } 75 78 76 79 private: … … 83 86 }; 84 87 85 template <typename T>86 inline bool operator==(const Iterator<T>& lhs,87 const Iterator<T>& rhs)88 89 90 88 template <typename T1, typename T2> 89 inline bool operator==(const Iterator<T1,T2>& lhs, 90 const Iterator<T1,T2>& rhs) 91 { 92 return lhs.equal(rhs); 93 } 91 94 92 template <typename T>93 inline bool operator!=(const Iterator<T>& lhs,94 const Iterator<T>& rhs)95 96 97 98 99 100 template <typename T>101 inline bool operator<(const Iterator<T>& lhs,102 const Iterator<T>& rhs)103 104 105 106 107 108 template <typename T>109 inline bool operator<=(const Iterator<T>& lhs,110 const Iterator<T>& rhs)111 112 113 114 115 116 template <typename T>117 inline bool operator>(const Iterator<T>& lhs,118 const Iterator<T>& rhs)119 120 121 122 123 124 template <typename T>125 inline bool operator>=(const Iterator<T>& lhs,126 const Iterator<T>& rhs)127 128 129 95 template <typename T1, typename T2> 96 inline bool operator!=(const Iterator<T1,T2>& lhs, 97 const Iterator<T1,T2>& rhs) 98 { 99 return !(lhs==rhs); 100 } 101 102 103 template <typename T1, typename T2> 104 inline bool operator<(const Iterator<T1,T2>& lhs, 105 const Iterator<T1,T2>& rhs) 106 { 107 return lhs<rhs; 108 } 109 110 111 template <typename T1, typename T2> 112 inline bool operator<=(const Iterator<T1,T2>& lhs, 113 const Iterator<T1,T2>& rhs) 114 { 115 return !(rhs<lhs); 116 } 117 118 119 template <typename T1, typename T2> 120 inline bool operator>(const Iterator<T1,T2>& lhs, 121 const Iterator<T1,T2>& rhs) 122 { 123 return rhs<lhs; 124 } 125 126 127 template <typename T1, typename T2> 128 inline bool operator>=(const Iterator<T1,T2>& lhs, 129 const Iterator<T1,T2>& rhs) 130 { 131 return !(lhs<rhs); 132 } 130 133 131 134 -
trunk/yat/utility/Makefile.am
r880 r881 32 32 33 33 include_utility_HEADERS = \ 34 Alignment.h constIterator.hException.h FileUtil.h Iterator.h \34 Alignment.h Exception.h FileUtil.h Iterator.h \ 35 35 kNNI.h matrix.h NNI.h \ 36 36 PCA.h stl_utility.h SVD.h TypeInfo.h utility.h vector.h WeNNI.h -
trunk/yat/utility/vector.h
r880 r881 89 89 public: 90 90 91 typedef Iterator< vector> iterator;92 typedef constIterator<const vector> const_iterator;91 typedef Iterator<double&, vector> iterator; 92 typedef Iterator<const double, const vector> const_iterator; 93 93 94 94 /**
Note: See TracChangeset
for help on using the changeset viewer.