Std::iterator
Features
-
++it
,it++
가 정의 될 것. 단++it
는 자기 자신의 타입의 리퍼런스를 반환해야함. -
"*it = 값"
이 정의되어야함. (중요) - 다시 이전 iterator를 접근하는 일은 없음.
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++ - iterator 의 구현
- STL: 반복자 iterator 개념 및 예제
- iterator: C++의 포인터 추상화
- [추천] SGI: Iterators
- C++ - iterator 의 구현
- C++ Iterators
- 혼자 연구하는 C/C++ by WinApi - 39-2-바.반복자의 속성
- [추천] C++.STL - 2장: 반복자(iterator) 2