|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi!
What's the relation between std::iterator and the iterators provided by various containers? How do the concepts of five categories of iterators be implementated by these iterator classes including std::iterator and various container iterators? Thank you for your time. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
lovecreatesbea...@gmail.com a écrit :
> Hi! > > What's the relation between std::iterator and the iterators provided > by various containers? How do the concepts of five categories of > iterators be implementated by these iterator classes including > std::iterator and various container iterators? std::iterator only defines a bunch of typedefs. It is basically an er class; you can define an iterator without inheriting from it, provided to provide the relevant nested typedefs. The various iterators concepts are described in STL SGI: http://www.sgi.com/tech/stl/Iterators.html - InputIterators may be dereferenced for reading and can only be incremented and a range cannot be used more than once. - OutputIterators can be dereferenced for writing and can only be incremented and a range cannot be used more than once. - ForwardIterators guarantee that you can use a range more than once (by example if you have an algorithm with more than one pass). But they can only be increamented (like in a simple list). - BidirectionalIterators are like the ForwardIterators but iterators can be decremented (like in a double ended list). - RandomIterators are like BidirectionalIterators but you can directly access an iterator at a given distance from another iterator (typically an array). Michael |
|
![]() |
| Outils de la discussion | |
|
|