I have a List
of nodes, where each node has some coordinates.
public class Node
{
float x,y;
....
}
List<Node> myNodeList;
I need to remove each node from the list that has a distance less of a given threshold from its adjacent nodes. I read this post explaining how remove elements from a collection while iterating it.
I'd prefer using RemoveAll
way, instead of iterating the list in reverse order because I think it's cleaner and more elegant.
My problem is that I need to access the adjacent elements of the current item, to calculate the distance.
Is there any clean way to do that?
I need something like:
myNodeList.RemoveAll(item => DistanceLessThanThreshold (item.Value, nextNode) && DistanceLessThanThreshold (item.Value, prevNode);
Is that possible?