Page 2 of 2
Re: [Solved] STL Question
Posted: Mon Jun 22, 2009 4:35 pm
by zodiac976
MarauderIIC wrote:Vectors have reverse. The documentation even uses reverse in its example
http://www.sgi.com/tech/stl/reverse.html
Your indentation is off on your file.close(), by the way.
And I guess you could do list+vector, I mean, I can't think of any real reason to not do it, unless copying between the two is slow.
Yep fixed that my bad
. The reversing I was talking about was
from this site
http://www.cplusplus.com/reference/stl/list/reverse/.
I can't find this function for the vector but I just used a reverse iterator.
I use the functions under the #include <vector> and <list>. I should check
out this <algorithm>
.
Re: STL Question [Solved]
Posted: Mon Jun 22, 2009 4:39 pm
by MarauderIIC
I see. reverse() does the same thing, but I don't know if there's a difference in speed between reverse() and .reverse()
Re: STL Question [Solved]
Posted: Mon Jun 22, 2009 4:42 pm
by zodiac976
Yea but when it comes to what is efficient speed-wise I am a
complete newbie on that but thanks to you I know the difference
in a vector and list speed
.
Re: STL Question [Solved]
Posted: Mon Jun 22, 2009 4:45 pm
by MarauderIIC
Oh, you should get into the habit of doing ++i instead of i++ to advance things in for-loops. Since the result is the same -- only because there's no other statements in the line of code (as delimited by ';') -- it's faster to do ++i instead of i++. There's a couple things in this forum about that, and a link in the Guides & Resources thread.
Re: STL Question [Solved]
Posted: Mon Jun 22, 2009 4:54 pm
by zodiac976
Yea I learned that from my instructor x++
, anywho I will
take a look at that, thanks again
.