Foward iterators

Discussion in 'C++' started by Dave, May 17, 2005.

  1. Dave

    Dave Guest

    Can anybody offer a specific example of an iterator that has the
    capabilities of a forward iterator but no more?
     
    Dave, May 17, 2005
    #1
    1. Advertising

  2. "Dave" <> wrote in message
    news:...

    > Can anybody offer a specific example of an iterator that has the
    > capabilities of a forward iterator but no more?


    Look at the sequence class in chapter 15 of "Ruminations on C++."

    That class offers behavior similar to Lisp lists, but with the restriction
    that all elements of a sequence must have the same type. It also has the
    interesting property that the container and iterator classes are the same
    type.
     
    Andrew Koenig, May 17, 2005
    #2
    1. Advertising

  3. In article <>,
    "Dave" <> wrote:

    > Can anybody offer a specific example of an iterator that has the
    > capabilities of a forward iterator but no more?


    The iterators of a singly linked list are such an example. You can't
    iterate backwards (in constant time).

    -Howard
     
    Howard Hinnant, May 17, 2005
    #3
  4. Dave

    Andre Kostur Guest

    Howard Hinnant <> wrote in news:hinnant-
    :

    > In article <>,
    > "Dave" <> wrote:
    >
    >> Can anybody offer a specific example of an iterator that has the
    >> capabilities of a forward iterator but no more?

    >
    > The iterators of a singly linked list are such an example. You can't
    > iterate backwards (in constant time).
    >
    > -Howard
    >


    Or an istream iterator....
     
    Andre Kostur, May 17, 2005
    #4
  5. In article <Xns96597434BA43Cnntpspamkosturnet@207.35.177.135>,
    Andre Kostur <> wrote:

    > Howard Hinnant <> wrote in news:hinnant-
    > :
    >
    > > In article <>,
    > > "Dave" <> wrote:
    > >
    > >> Can anybody offer a specific example of an iterator that has the
    > >> capabilities of a forward iterator but no more?

    > >
    > > The iterators of a singly linked list are such an example. You can't
    > > iterate backwards (in constant time).
    > >
    > > -Howard
    > >

    >
    > Or an istream iterator....


    Actually not really, at least if we're using the std::definition of
    "forward". A std::istream_iterator fails to meet the forward spec
    because it can not be used in multi-pass algorithms. The standard terms
    iterators in this class as "input iterators" which have a subset of the
    functionality of forward iterators.

    -Howard
     
    Howard Hinnant, May 17, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Sprague
    Replies:
    4
    Views:
    703
  2. Marcin Kaliciñski

    Iterators and reverse iterators

    Marcin Kaliciñski, May 8, 2005, in forum: C++
    Replies:
    1
    Views:
    510
    Kai-Uwe Bux
    May 8, 2005
  3. Replies:
    0
    Views:
    379
  4. John Watson

    Foward referencing broken?

    John Watson, Apr 1, 2007, in forum: C++
    Replies:
    5
    Views:
    396
    Keith Davies
    Apr 1, 2007
  5. , India
    Replies:
    10
    Views:
    1,099
    James Kanze
    Aug 8, 2009
Loading...

Share This Page