Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mage2k

<vector> problem

This topic is 5668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok. Here''s the problem: I am writing an inheritance hiearchy for scene graph nodes. I am using s to hold a node''s children list. For some reason I cannot add more than one item to any given . Here''s what happens: after I add one element (Node*) to a the First and Last iterator''s should both point to the same (the only) element, correct? Unfortunately, when debugging (in vc++ 6.0) I see that the First iterator is set to point to the element, but not the Last iterator which doesn''t point to anything. This obviously causes a problem with adding more elements, which then results in whole branches of a scene graph not being processed/drawn. I have repeated this behavior with someone else''s code so I know it''s not me. (Yes, I have asked the person who wrote the other code, but have not heard back from them.) Any ideas on what is going on?

Share this post


Link to post
Share on other sites
Advertisement
First of all, you can't use < and > in your text like that; enclosed text is interpreted as tags and rendered invisible.

For the question itself: What do you mean by 'First' and 'Last'? The vector class has two functions that return iterators, called begin() and end() - begin() returns an iterator to the first element, while end() returns an iterator which points one element beyond the last element (so that the last element is end()-1). There are also the functions front() and back(), returning (constant) references to the first and last elements, respectively.

This, of course, is all in the MSDN docs that ship with VC++.

[edited by - Miserable on February 7, 2003 6:10:44 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Don''t use VC++6''s STL; it''s buggy and slow. Download STLPort.

Share this post


Link to post
Share on other sites
hehe... sorry about the s... wasn''t thinking... as far as First and Last go, the watch window in vc++ list''s my vectors as having members: alloc, _First, _Last, and _End which equate to the relevant pointers (which iterators essentaially are) into the vector, i.e they point to what would be returned by front() and back() and end().

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!