30 #ifndef __CLAW_IT_INDEX_HPP__
31 #define __CLAW_IT_INDEX_HPP__
45 typedef typename std::iterator_traits<T>::value_type value_type;
46 typedef typename std::iterator_traits<T>::difference_type difference_type;
47 typedef typename std::iterator_traits<T>::pointer pointer;
48 typedef typename std::iterator_traits<T>::reference reference;
69 : m_it(it), m_index(index)
77 : m_it( that.m_it ), m_index( that.m_index )
85 void set(
const T& it,
int index )
91 bool operator<( const it_index<T>& that )
const
92 {
return m_index < that.m_index; }
94 bool operator<(
const T& it )
const {
return m_it < it; }
95 bool operator<(
int index )
const {
return m_index < index; }
97 bool operator<=( const it_index<T>& that )
const
98 {
return (*
this < that) || (*
this == that); }
99 bool operator<=(
const T& it )
const {
return m_it <= it; }
100 bool operator<=(
int index )
const {
return m_index <= index; }
102 bool operator>(
const it_index<T>& that )
const
103 {
return m_index > that.m_index; }
104 bool operator>(
const T& it )
const {
return m_it > it; }
105 bool operator>(
int index )
const {
return m_index > index; }
107 bool operator>=(
const it_index<T>& that )
const
108 {
return (*
this > that) || (*
this == that); }
109 bool operator>=(
const T& it )
const {
return m_it >= it; }
110 bool operator>=(
int index )
const {
return m_index >= index; }
112 bool operator==(
const it_index<T>& that )
const
113 {
return (m_it == that.m_it) && (m_index == that.m_index); }
114 bool operator==(
const T& it )
const {
return m_it == it; }
115 bool operator==(
int index )
const {
return m_index==index; }
117 bool operator!=(
const it_index<T>& that )
const
118 {
return !(*
this == *that); }
119 bool operator!=(
const T& it )
const {
return m_it != it; }
120 bool operator!=(
int index )
const {
return m_index!=index; }
122 it_index<T> operator+(
int index )
const
123 {
return it_index<T>(m_it + index, m_index + index); }
124 it_index<T> operator-(
int index )
const
125 {
return it_index<T>(m_it - index, m_index - index); }
126 it_index<T> operator*(
int index )
const
127 {
return it_index<T>(m_it + (index-1) * m_index, m_index * index); }
128 it_index<T> operator/(
int index )
const
129 {
return it_index<T>(m_it - (m_index - m_index/index), m_index / index); }
131 reference operator*()
const {
return *m_it; }
132 pointer operator->()
const {
return &*m_it; }
135 it_index<T>& operator++()
143 it_index<T> operator++(
int)
145 it_index<T> r(*
this);
151 it_index<T>& operator--()
159 it_index<T> operator--(
int)
161 it_index<T> r(*
this);
166 it_index<T>& operator+=(
int index )
173 it_index<T>& operator-=(
int index )
180 it_index<T>& operator*=(
int index )
182 m_it += (index-1) * m_index;
187 it_index<T>& operator/=(
int index )
189 m_it -= m_index - m_index/index;
194 operator int()
const {
return m_index; }
195 operator T()
const {
return m_it; }
201 #endif // __CLAW_IT_INDEX_HPP__