for-loop question

Here is a for-loop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
for(unsigned long long j = 0; j <= 1000000; j++)
{
	timeStep = j*timeDelta / 1000000;
			
	x = forceX*timeStep*timeStep / 2.0L + directionX*timeStep + tempIX;
	y = forceY*timeStep*timeStep / 2.0L + directionY*timeStep + tempIY;
	z = forceZ*timeStep*timeStep / 2.0L + directionZ*timeStep + tempIZ;
			
	if((R - sqrt(x*x + y*y))*(R - sqrt(x*x + y*y)) + z*z >= (r-PARTICLE_SIZE)*(r-PARTICLE_SIZE))
	{
	        approximateParticleSize = r - sqrt((R - sqrt(x*x + y*y))*(R - sqrt(x*x + y*y)) + z*z);
				
		if(minParticleSize > approximateParticleSize) minParticleSize = approximateParticleSize;
		if(maxParticleSize < approximateParticleSize) maxParticleSize = approximateParticleSize;
				
		approximateParticleSizeSUM++;
		approximateParticleSizeSUMTotal += approximateParticleSize;
				
		if(timeStep < minimumTimeStep)
		{
		        minimumTimeStep = timeStep;
		
	                eventCollision->time = timeStep;
		        eventCollision->i = i;
		        eventCollision->wallCollision = true;
		}
		else if(timeStep == minimumTimeStep)
		{
			eventCollision->time = timeStep;
			eventCollision->i = i;
			eventCollision->wallCollision = true;
			
			timeVectorPhi.push_back(eventCollision);
		}
				
		collisionAlarm = true;
				
		break;
	}
}


My question is simply about the break; statement at the end... it is inside an "if()" statement... so is it just gonna break me out of the if or from the for-loop aswell??

Thanks,
AeonFlux1212
Last edited on
It breaks you out of the loop.
ok thanks... that's what I was hoping for... :-)
break takes you out of all of the loops
Topic archived. No new replies allowed.