
please wait
|
|
and has the following (x,y) values associated with each struct: [(1,1), (1,1), (2,3), (2,3), (3,5), (3,5), (5,1), (5,1), (5,4), (5,4)] |
|
|
I didn't realise I couldn't modify the vector from the iterator. |
|
|
0 1 2 3 4 5 6 7 8 9 1 3 5 7 9 |
|
|
|
|
pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> pos: (1, 1); penguins: 13; max j: 666; curr j: 1; input? false; parent: 0; --> pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> pos: (2, 3); penguins: 13; max j: 666; curr j: 3; input? false; parent: 0; --> pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> pos: (3, 5); penguins: 13; max j: 666; curr j: 5; input? false; parent: 0; --> pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> pos: (5, 1); penguins: 13; max j: 666; curr j: 7; input? false; parent: 0; --> pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> pos: (5, 4); penguins: 13; max j: 666; curr j: 9; input? false; parent: 0; --> odds now: pos: (1, 1); penguins: 13; max j: 666; curr j: 1; input? false; parent: 0; --> evens now: pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> evens now: pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> evens now: pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> evens now: pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> evens now: pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> odds now: pos: (2, 3); penguins: 13; max j: 666; curr j: 3; input? false; parent: 0; --> evens now: pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> evens now: pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> evens now: pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> evens now: pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> evens now: pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> odds now: pos: (3, 5); penguins: 13; max j: 666; curr j: 5; input? false; parent: 0; --> evens now: pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> evens now: pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> evens now: pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> evens now: pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> evens now: pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> odds now: pos: (5, 1); penguins: 13; max j: 666; curr j: 7; input? false; parent: 0; --> evens now: pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> evens now: pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> evens now: pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> evens now: pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> evens now: pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> odds now: pos: (5, 4); penguins: 13; max j: 666; curr j: 9; input? false; parent: 0; --> evens now: pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> evens now: pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> evens now: pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> evens now: pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> evens now: pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> pos: (1, 1); penguins: 13; max j: 666; curr j: 0; input? false; parent: 0; --> pos: (1, 1); penguins: 13; max j: 666; curr j: 1; input? false; parent: 0; --> 0, 2, 4, 6, 8, pos: (2, 3); penguins: 13; max j: 666; curr j: 2; input? false; parent: 0; --> pos: (2, 3); penguins: 13; max j: 666; curr j: 3; input? false; parent: 0; --> 0, 2, 4, 6, 8, pos: (3, 5); penguins: 13; max j: 666; curr j: 4; input? false; parent: 0; --> pos: (3, 5); penguins: 13; max j: 666; curr j: 5; input? false; parent: 0; --> 0, 2, 4, 6, 8, pos: (5, 1); penguins: 13; max j: 666; curr j: 6; input? false; parent: 0; --> pos: (5, 1); penguins: 13; max j: 666; curr j: 7; input? false; parent: 0; --> 0, 2, 4, 6, 8, pos: (5, 4); penguins: 13; max j: 666; curr j: 8; input? false; parent: 0; --> pos: (5, 4); penguins: 13; max j: 666; curr j: 9; input? false; parent: 0; --> 0, 2, 4, 6, 8, |
You are trying to modify the vector while iterating over it |
vector::iterator
. It's much clearer to use an index, at least it is to me. It's less error prone too as we're about to find out :)for (auto outputNodePtr = next( floes.begin() ); outputNodePtr != floes.end(); advance(outputNodePtr, 2) )
for (auto inputNodePtr = floes.begin(); inputNodePtr != prev( floes.end() ); advance(inputNodePtr, 2) )
|
|
Does this mean that when I add to my vector I actually end up overwriting a bit of the next struct in the vector? |
return 0;
at the end.