Embedded Template Library 1.0
Loading...
Searching...
No Matches
fixed_iterator.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2015 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_FIXED_ITERATOR_INCLUDED
32#define ETL_FIXED_ITERATOR_INCLUDED
33
34#include "platform.h"
35#include "iterator.h"
36
38
39namespace etl
40{
45 template <typename TIterator>
46 class fixed_iterator : etl::iterator<typename etl::iterator_traits<TIterator>::iterator_category, typename etl::iterator_traits<TIterator>::value_type>
47 {
48 public:
49
50 //***************************************************************************
52 //***************************************************************************
54 : it(TIterator())
55 {
56 }
57
58 //***************************************************************************
60 //***************************************************************************
62 : it(it_)
63 {
64 }
65
66 //***************************************************************************
68 //***************************************************************************
70 : it(other.it)
71 {
72 }
73
74 //***************************************************************************
76 //***************************************************************************
78 {
79 return *this;
80 }
81
82 //***************************************************************************
84 //***************************************************************************
86 {
87 return *this;
88 }
89
90 //***************************************************************************
92 //***************************************************************************
94 {
95 return *this;
96 }
97
98 //***************************************************************************
100 //***************************************************************************
102 {
103 return *this;
104 }
105
106 //***************************************************************************
108 //***************************************************************************
109 typename etl::iterator_traits<TIterator>::value_type operator *()
110 {
111 return *it;
112 }
113
114 //***************************************************************************
116 //***************************************************************************
117 const typename etl::iterator_traits<TIterator>::value_type operator *() const
118 {
119 return *it;
120 }
121
122 //***************************************************************************
124 //***************************************************************************
126 {
127 return it;
128 }
129
130 //***************************************************************************
132 //***************************************************************************
133 const TIterator operator ->() const
134 {
135 return it;
136 }
137
138 //***************************************************************************
140 //***************************************************************************
141 operator TIterator() const
142 {
143 return it;
144 }
145
146 //***************************************************************************
148 //***************************************************************************
149 fixed_iterator& operator +=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
150 {
151 return *this;
152 }
153
154 //***************************************************************************
156 //***************************************************************************
157 fixed_iterator& operator -=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
158 {
159 return *this;
160 }
161
162 //***************************************************************************
164 //***************************************************************************
166 {
167 it = new_it;
168 return *this;
169 }
170
171 //***************************************************************************
173 //***************************************************************************
175 {
176 it = other.it;
177 return *this;
178 }
179
180 private:
181
182 TIterator it;
183 };
184
185 //*****************************************************************************
187 //*****************************************************************************
188 template <typename TIterator>
190 typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
191 {
192 return lhs;
193 }
194
195 //*****************************************************************************
197 //*****************************************************************************
198 template <typename TIterator>
200 typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
201 {
202 return lhs;
203 }
204
205 //*****************************************************************************
207 //*****************************************************************************
208 template <typename TIterator>
209 typename etl::iterator_traits<TIterator>::difference_type operator -(const etl::fixed_iterator<TIterator>& lhs,
211 {
212 return TIterator(lhs) - TIterator(rhs);
213 }
214
215 //*****************************************************************************
217 //*****************************************************************************
218 template <typename TIterator>
224
225 //*****************************************************************************
227 //*****************************************************************************
228 template <typename TIterator>
231 {
232 return TIterator(lhs) == rhs;
233 }
234
235 //*****************************************************************************
237 //*****************************************************************************
238 template <typename TIterator>
241 {
242 return lhs == TIterator(rhs);
243 }
244
245
246 //*****************************************************************************
248 //*****************************************************************************
249 template <typename TIterator>
252 {
253 return !(lhs == rhs);
254 }
255
256 //*****************************************************************************
258 //*****************************************************************************
259 template <typename TIterator>
262 {
263 return !(lhs == rhs);
264 }
265
266 //*****************************************************************************
268 //*****************************************************************************
269 template <typename TIterator>
272 {
273 return !(lhs == rhs);
274 }
275}
276
277#endif
fixed_iterator()
Default constructor.
Definition fixed_iterator.h:53
TIterator operator->()
-> operator.
Definition fixed_iterator.h:125
fixed_iterator & operator++()
Increment (Does nothing).
Definition fixed_iterator.h:77
etl::iterator_traits< TIterator >::value_type operator*()
Dereference operator.
Definition fixed_iterator.h:109
fixed_iterator & operator=(TIterator new_it)
Assignment from iterator.
Definition fixed_iterator.h:165
fixed_iterator & operator+=(typename etl::iterator_traits< TIterator >::difference_type)
+= operator.
Definition fixed_iterator.h:149
fixed_iterator & operator--()
Decrement (Does nothing).
Definition fixed_iterator.h:93
fixed_iterator(TIterator it_)
Construct from iterator.
Definition fixed_iterator.h:61
fixed_iterator(const fixed_iterator &other)
Copy constructor.
Definition fixed_iterator.h:69
fixed_iterator & operator-=(typename etl::iterator_traits< TIterator >::difference_type)
-= operator.
Definition fixed_iterator.h:157
Definition fixed_iterator.h:47
bitset_ext
Definition absolute.h:38
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator-(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:672
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:654
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:642
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator+(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:659
iterator
Definition iterator.h:399
pair holds two objects of arbitrary type
Definition utility.h:164