relation between std::iterator and other container iterators

  • Thread starter lovecreatesbea...
  • Start date
L

lovecreatesbea...

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.
 
M

Michael DOUBEZ

(e-mail address removed) 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top