Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Conditional vec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 9372 of 10087
Post > Topic >>

Conditional vector iteration ( quite tricky ! )

by isometric_god@[EMAIL PROTECTED] Mar 13, 2008 at 02:42 AM

Dear fellow programmers,

I am struggling quite a bit with this small snippet of code. The only
thing missing is the iteration through the lists, but this part is not
as simple as it seems.

They lists are std::vector<CObject*>, the iterators fit and eit are
std::vector<CObject*>::iterators, which should be irrelevant though.

	...
	fit = m_Friend.begin();
	while (fit != m_Friend.end())
	{
		eit = m_Enemy.begin();
		while (eit != m_Enemy.end())
		{
			if ((*fit)->TestCollisionWith(*eit))
			{
				(*fit)->CollideWith(*eit);
				(*eit)->CollideWith(*fit);

				if ((*eit)->IsDead())
				{
					m_Kill.push_back(*eit);
					eit = m_Enemy.erase(eit);
				}

				if ((*fit)->IsDead())
				{
					m_Kill.push_back(*fit);
					fit = m_Friend.erase(fit);
					eit = m_Enemy.begin();
				}
			}

			// conditional incrementation of eit
		}
		// conditional incrementation of fit
	}
	...

Anyone got a bright thought on this issue? I'm curious to hear your
ideas !

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 4 Posts in Topic:
Conditional vector iteration ( quite tricky ! )
isometric_god@[EMAIL PROT  2008-03-13 02:42:40 
Re: Conditional vector iteration ( quite tricky ! )
Carl Barron <cbarron41  2008-03-13 12:01:05 
Re: Conditional vector iteration ( quite tricky ! )
"oliver.g.charles@[E  2008-03-13 12:00:24 
Re: Conditional vector iteration ( quite tricky ! )
Martin York <Martin.Yo  2008-03-13 16:31:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 16:37:48 CDT 2008.