[Solved] STL Question

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: [Solved] STL Question

Post 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 :lol:. 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> :).
Last edited by zodiac976 on Tue Jun 23, 2009 12:42 pm, edited 1 time in total.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: STL Question [Solved]

Post 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()
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: STL Question [Solved]

Post 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 :).
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: STL Question [Solved]

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: STL Question [Solved]

Post by zodiac976 »

Yea I learned that from my instructor x++ :roll:, anywho I will
take a look at that, thanks again ;).
Post Reply