Results 1 to 3 of 3

Thread: ::iterator

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Question ::iterator

    Hello,
    I have a prob.
    Qt Code:
    1. vector<Some> some(10);
    2. vector<Some>::iterator ii;
    3. vector<Some>::iterator cc;
    To copy to clipboard, switch view to plain text mode 
    assuming that ii is at the last element of some I need to do:
    Qt Code:
    1. cc=ii+1 //I'm out
    2. if (cc <= some.size()) ....
    To copy to clipboard, switch view to plain text mode 
    In other words i need to know when ii+1 is an iterator more large of 10 (number of elements of verctor)
    Thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ::iterator

    vector<...>::end() points behind last element.

    Qt Code:
    1. for( vector<int>::iterator i = v.begin(); i != v.end(); ++i ) {
    2. // ...
    3. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: ::iterator

    Try this ...

    Qt Code:
    1. cc = ++ii;
    2. if(cc != some.end())
    3. ...
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. pointer and iterator
    By mickey in forum General Programming
    Replies: 6
    Last Post: 3rd February 2008, 23:24
  2. QLinkedList iterator
    By ^NyAw^ in forum Qt Programming
    Replies: 8
    Last Post: 18th October 2007, 17:15
  3. iterator
    By mickey in forum General Programming
    Replies: 6
    Last Post: 23rd May 2006, 11:28
  4. Std iterator as private member variable
    By Michiel in forum General Programming
    Replies: 5
    Last Post: 21st April 2006, 16:27
  5. convert iterator
    By mickey in forum General Programming
    Replies: 8
    Last Post: 20th March 2006, 22:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.