Click here to Skip to main content
15,899,679 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: STL Algorithms Pin
Stephen Hewitt13-Sep-06 14:14
Stephen Hewitt13-Sep-06 14:14 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 18:32
Zac Howland13-Sep-06 18:32 
GeneralRe: STL Algorithms [modified] Pin
Stephen Hewitt13-Sep-06 19:32
Stephen Hewitt13-Sep-06 19:32 
GeneralRe: STL Algorithms Pin
Zac Howland14-Sep-06 3:13
Zac Howland14-Sep-06 3:13 
GeneralRe: STL Algorithms Pin
Stephen Hewitt14-Sep-06 13:50
Stephen Hewitt14-Sep-06 13:50 
GeneralRe: STL Algorithms Pin
Zac Howland14-Sep-06 19:17
Zac Howland14-Sep-06 19:17 
GeneralRe: STL Algorithms Pin
Stephen Hewitt14-Sep-06 19:27
Stephen Hewitt14-Sep-06 19:27 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 3:21
Zac Howland13-Sep-06 3:21 
Steve Echols wrote:
This makes much more sense to me (but I'm old school):

vector<whatever> vec;
for (int i = 0; i < vec.size(); i++)
{
}

than

vector<whatever> vec;
vector<whatever>::iterator it;
for (it = vec.begin(); it != vec.end(); it++)
{
}


See, but neither is "correct". Assume you are calling DoSomething(const whatever& w) for each iteration of the loop. The entire loop can be written as follows:

vector<whatever> vec;
// fill it somewhere
// DoSomething is declared and implemented somewhere
for_each(vec.begin(), vec.end(), DoSomething);


Using iterators in place of the index doesn't buy you anything in terms of taking advantage of the pre-made algorithms STL gives you.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

AnswerRe: STL Algorithms Pin
Kevin McFarlane13-Sep-06 4:08
Kevin McFarlane13-Sep-06 4:08 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 4:23
Zac Howland13-Sep-06 4:23 
GeneralRe: STL Algorithms Pin
Kevin McFarlane13-Sep-06 9:01
Kevin McFarlane13-Sep-06 9:01 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 9:17
Zac Howland13-Sep-06 9:17 
AnswerRe: STL Algorithms Pin
Stephen Hewitt13-Sep-06 22:52
Stephen Hewitt13-Sep-06 22:52 
GeneralRe: STL Algorithms Pin
Rob Caldecott13-Sep-06 23:40
Rob Caldecott13-Sep-06 23:40 
GeneralRe: STL Algorithms Pin
Stuart Dootson14-Sep-06 1:17
professionalStuart Dootson14-Sep-06 1:17 
GeneralRe: STL Algorithms Pin
Zac Howland14-Sep-06 3:17
Zac Howland14-Sep-06 3:17 
GeneralRe: STL Algorithms Pin
Nemanja Trifunovic15-Sep-06 4:43
Nemanja Trifunovic15-Sep-06 4:43 
GeneralRe: STL Algorithms Pin
Zac Howland15-Sep-06 5:26
Zac Howland15-Sep-06 5:26 
GeneralRe: STL Algorithms Pin
Stuart Dootson15-Sep-06 5:43
professionalStuart Dootson15-Sep-06 5:43 
GeneralRe: STL Algorithms Pin
Rob Caldecott17-Sep-06 23:49
Rob Caldecott17-Sep-06 23:49 
GeneralRe: STL Algorithms Pin
Stephen Hewitt18-Sep-06 0:34
Stephen Hewitt18-Sep-06 0:34 
GeneralRe: STL Algorithms Pin
Rob Caldecott18-Sep-06 4:06
Rob Caldecott18-Sep-06 4:06 
GeneralRe: STL Algorithms Pin
Stephen Hewitt18-Sep-06 13:48
Stephen Hewitt18-Sep-06 13:48 
GeneralRe: STL Algorithms Pin
Rob Caldecott19-Sep-06 0:03
Rob Caldecott19-Sep-06 0:03 
QuestionHyperlinks on MenuItems Pin
PrafullaT11-Sep-06 22:11
PrafullaT11-Sep-06 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.