::iterate

This is a discussion on ::iterate within the C++ Programming forums, part of the General Programming Boards category; I have a way to ::iterate the dimensions for a vector as in the first code. Now I am using ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    383

    ::iterate

    I have a way to ::iterate the dimensions for a vector as in the first code.
    Now I am using a List as in the second code and looking for
    how this list will iterate in the same way as for the vector but have problem to find examples of this.
    I have begun some code for the list but something might be missing.

    (std::vector)
    Code:
    typedef std::vector<string> One;
    typedef std::vector<One> Two;
    typedef std::vector<Two> Three;
    
    Three Listing;	
    
    for (Three::iterator a = Listing.begin(); a != Listing.end(); ++a) 
    {
    for (Two::iterator b = a->begin(); b != a->end(); ++b)			
    {
    for (One::iterator c = b->begin(); c != b->end(); ++c)			
    {}}}
    (List)
    Code:
    typedef List<String^> One;
    typedef List<One^> Two;
    typedef List<Two^> Three;
    
    Three Listing;	
    
    for(int a = 0; a < Three().Count + 1; ++a)
    {
    for(int b = 0; b < Two().Count + 1; ++b)
    {
    for(int c = 0; c < One().Count + 1; ++c)
    {}}}

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    You can do the same for lists as you do with vectors, using iterators

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Note, though, that's List, not std::list (as was stipulated in the vector example). Is this a CLI List? I don't know about iterators with that, but I'm sure there's an easy way to iterate through it, but having never used it I don't know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Iterate through every file in a directory
    By Sharke in forum C Programming
    Replies: 5
    Last Post: 04-13-2009, 11:12 AM
  2. iterate through keys of map
    By lord in forum C++ Programming
    Replies: 7
    Last Post: 10-30-2008, 11:34 AM
  3. iterate through types in a library (reflection)
    By bling in forum C++ Programming
    Replies: 1
    Last Post: 10-29-2008, 06:15 PM
  4. Iterate variable (newbie)
    By Roffemuffe in forum C Programming
    Replies: 5
    Last Post: 10-15-2008, 08:50 AM
  5. iterate a 3d vector
    By Coding in forum C++ Programming
    Replies: 12
    Last Post: 07-31-2008, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21