I have LinkedList nodes, each of which stores LinkedList edges. I wanted to do something line by line
nodes.RemoveAll(n => n.edges.Count == 0)
But without RemoveAll, this happens. I donβt understand why he doesnβt have it, as other collections do. This would have to go through all the elements and delete only one of what I understand would not be bad performance for a linked list.
Now I have to do this instead:
for (LinkedListNode<MyNode> n2 = nodes.First; n2 != null; ) { LinkedListNode<MyNode> temp = n2.Next; if (n2.Value.edges.Count == 0) nodes.Remove(n2); n2 = temp; }
As long as it works, it makes things more complex than what they are.
collections c #
zxcvbnm
source share