Programming Wiki: C STL Vectors

Programming Wiki : CppVectorTips

WikiHomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Most recent edit on 2006-04-28 01:00:33 by ScottRippee [reorganized header]


C++ STL Vectors




Cpp STL Vectors

Edited on 2006-04-01 01:23:26 by ScottRippee

No differences.

Oldest known version of this page was edited on 2006-04-01 01:23:11 by ScottRippee []
Page view:


Cpp STL Vectors

Using the vector find method

    vector<string>::iterator viter;
    vector<string>::iterator start = myVec.begin();
    vector<string>::iterator end = myVec.end();

    // Search our vector to see if item has already been inserted
    viter = find( start, end, myStringToSearchFor );
    if( viter == end )
        // Device not found lets insert

I tried doing the above without setting an iterator to the start and end for find but it never found a match. For example find (myVec.begin(), myVec.end(), SearchString) would never be able to find the search string.

Iterating through a stl vector

    vector<string>::const_iterator viter;
    for( viter=myVec.begin(); viter != myVec.end(); viter++ )
          //do stuff
Powered by Wikka Wakka Wiki
Page was generated in 0.0330 seconds