Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   relation between std::iterator and other container iterators (http://www.velocityreviews.com/forums/t589821-relation-between-std-iterator-and-other-container-iterators.html)

lovecreatesbea...@gmail.com 02-06-2008 08:13 AM

relation between std::iterator and other container iterators
 
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.

Michael DOUBEZ 02-06-2008 10:34 AM

Re: relation between std::iterator and other container iterators
 
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
helper 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


All times are GMT. The time now is 08:29 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57