ring iterator adaptor for vector interator

Discussion in 'C++' started by PengYu.UT@gmail.com, Apr 2, 2006.

  1. Guest

    Suppose I want a ring_iterator, which is almost like the
    vector::iterator. But it will equals begin(), when it passed the end().
    It is easy to write an adaptor for it. But I'm wondering if there is
    any publicly available code for it.

    Thanks,
    Peng
     
    , Apr 2, 2006
    #1
    1. Advertising

  2. Daniel T. Guest

    In article <>,
    "" <> wrote:

    > Suppose I want a ring_iterator, which is almost like the
    > vector::iterator. But it will equals begin(), when it passed the end().
    > It is easy to write an adaptor for it. But I'm wondering if there is
    > any publicly available code for it.


    Do you want begin() == end() + 1, or do you want begin() == end()?


    --
    Magic depends on tradition and belief. It does not welcome observation,
    nor does it profit by experiment. On the other hand, science is based
    on experience; it is open to correction by observation and experiment.
     
    Daniel T., Apr 2, 2006
    #2
    1. Advertising

  3. Guest

    Daniel T. wrote:
    > In article <>,
    > "" <> wrote:
    >
    > > Suppose I want a ring_iterator, which is almost like the
    > > vector::iterator. But it will equals begin(), when it passed the end().
    > > It is easy to write an adaptor for it. But I'm wondering if there is
    > > any publicly available code for it.

    >
    > Do you want begin() == end() + 1, or do you want begin() == end()?
    >


    Sorry for the confusion. I want begin() == end().
     
    , Apr 2, 2006
    #3
  4. red floyd Guest

    wrote:
    > Daniel T. wrote:
    >> In article <>,
    >> "" <> wrote:
    >>
    >>> Suppose I want a ring_iterator, which is almost like the
    >>> vector::iterator. But it will equals begin(), when it passed the end().
    >>> It is easy to write an adaptor for it. But I'm wondering if there is
    >>> any publicly available code for it.

    >> Do you want begin() == end() + 1, or do you want begin() == end()?
    >>

    >
    > Sorry for the confusion. I want begin() == end().
    >


    Not a good idea. No standard algorithms will work in that case.

    for (T::iterator iter = c.begin();
    iter != c.end();
    ++iter)
    {
    // yada yada yada
    }

    Will not execute any loop iterations.
     
    red floyd, Apr 3, 2006
    #4
    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. Scott Smedley

    A different kind of adaptor iterator

    Scott Smedley, Dec 5, 2003, in forum: C++
    Replies:
    4
    Views:
    439
    Scott Smedley
    Dec 7, 2003
  2. Bengt Richter
    Replies:
    2
    Views:
    286
    Bengt Richter
    Sep 4, 2005
  3. Mathematician
    Replies:
    0
    Views:
    588
    Mathematician
    Dec 24, 2006
  4. Roedy Green

    OT ring ring

    Roedy Green, Aug 5, 2007, in forum: Java
    Replies:
    4
    Views:
    392
    Mike Schilling
    Aug 5, 2007
  5. Hicham Mouline
    Replies:
    1
    Views:
    594
    Hicham Mouline
    Apr 2, 2009
Loading...

Share This Page