How to not iterate on 0:values in an Array
I will give an example of what I am doing. I use a code that look like this:
Now is my question this:
std::vector<int> Integers(10); //This is my declared Array
for (int Calculate = 1; Calculate < 6; Calculate++) //The for loop
if Integers[Calculate] > 0
This for loop iterates on value from 1-5 with 1 in interval. So this meens 5 steps.
The Integers Array has in this case 5 positions with either a value of 0 or a value of 1 that I have stored from before.
As for the if-statement I am only interested of positions in the Array that are greater than 0, in this case positions that contain the number: 1.
An live example could look like this for the 5 positions in the Array.
0 1 1 0 0
In the example I am only interested to iterate on position 2 and 3 because the if statement wont execute on the 0:s anyway.
So what I am after is to "jump over" the 0 values. So instead of doing 5 steps in this case, only 2 will be made to increase speed...
Is this possible in any way to do ?