Std::iterator
lastmod 2018-08-17created 2015-03-208 edits
Features
-
++itandit++must be defined. However,++itmust return a reference to its own type. -
"*it = 값"must be defined. (Important) - A previous iterator is never accessed again.
Category
Category to which the iterator belongs to. It must be one of the following iterator tags:
| Iterator category | Defined operations | ||||
| ContiguousIterator | RandomAccessIterator | BidirectionalIterator | ForwardIterator | InputIterator |
|
| |||||
| |||||
| |||||
| |||||
| Iterators that fall into one of the above categories and also meet the requirements of OutputIterator are called mutable iterators. | |||||
| OutputIterator |
| ||||
Contiguous Iterator
RandomAccess Iterator
Bidirectional Iterator
Forward Iterator
Forward iterators are iterators that can be used to access the sequence of elements in a range in the direction that goes from its beginning towards its end.
Performing operations on a forward iterator that is dereferenceable never makes its iterator value non-dereferenceable. This enables algorithms that use this category of iterators to use multiple copies of an iterator to pass more than once by the same iterator values.
All bidirectional and random-access iterators are also valid forward iterators.
There is not a single type of forward iterator: Each container may define its own specific iterator type able to iterate through it and access its elements. But all forward iterators support -at least- the following operations:
| property | valid expressions |
| Is default-constructible1, copy-constructible, copy-assignable and destructible. |
|
| Can be compared for equivalence using the equality/inequality operators |
|
| Can be dereferenced as an rvalue (if in a dereferenceable state). |
|
| For mutable iterators (non-constant iterators): |
|
| Can be incremented (if in a dereferenceable state). |
|
| Lvalues are swappable. (C++11) |
|
Input Iterator
Output Iterator
Favorite site
- C++,STL :: Iterator
- Joinc: STL(4) - iterator
- C++ - Implementing an iterator
- STL: Iterator concepts and examples
- iterator: Pointer abstraction in C++
- [Recommended] SGI: Iterators
- C++ - Implementing an iterator
- C++ Iterators
- Studying C/C++ on Your Own by WinApi - 39-2-f. Properties of iterators
- [Recommended] C++.STL - Chapter 2: Iterator 2