How would I accomplish the following?
List A is a series of
Foo
s, list B is a series ofdouble
s representing time remaining until theFoo
at thei
th position of List A is removed. That is, if a double in List B is less than zero, theFoo
at the same position in List A as the less than zero double in List B is removed from List A and then the less-than-zero double is removed from List B.
List A:
A B C D E
List B (in seconds):
1.0 0.33 0.0 5.0 0.01
//1 tick of 0.33 seconds
List B:
0.67 0.0 -0.33 4.67 -0.32
//Remove offending List A elements based on state of List B
List A:
A B D
//Remove invalid List B elements
List B:
0.67 0.0 4.67
I'm thinking something along the lines of std::remove_if
for List B, but how would I remove the items for List A if I do that? Sadly, iterators of different lists aren't compatible and, except using manual implementations, there is no way to iterate through a list AND know the index of each value.
You might want to consider using a list of structures instead of two lists. Then you can use remove_if and other list functions.