How do you populate the index list? There is a more effective RemoveAll
method that you could use. For example, instead:
var indices = new List<int>(); int index = 0; foreach (var item in data) if (SomeFunction(data)) indices.Add(index++);
You can do it:
data.RemoveAll(item => SomeFunction(item));
This minimizes copying elements to new positions in the array; each item is copied only once.
You can also use method group conversion in the above example instead of lambda:
data.RemoveAll(SomeFunction);
phoog source share