CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    815

    looping on std:list

    can someone please give me an example of a loop going over items at std:list

    thanks

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725
    Code:
    list<T>::iterator it;
    
    for (it=my_list.begin(); it!=my_list.end(); ++it)
    {
       // *it has the value ofn the list element
    }

  3. #3
    Join Date
    Sep 2003
    Posts
    815
    thanks Philip

    I'll try to post in my new threads more "real" code
    another question:

    how can I retrive the data from the current list item, without removing it (meaning not using pop_front)

    I mean what can I do with mt iterator (it)
    Last edited by avi123; October 8th, 2003 at 11:39 AM.

  4. #4
    Join Date
    Aug 2002
    Posts
    58
    Inside Philip's loop

    Code:
    T item = *it;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured