KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a LinkedList of nodes each storing a LinkedList of edges. I wanted to do something along the lines of nodes.RemoveAll(n => n.edges.Count == 0) But without RemoveAll there goes that. I don't understand why it doesn't have it, since other collections do. This would have to iterate through all elements too and remove only one at a time from what I understand, which wouldn't be bad performancewise 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; } While it works, it makes things seem more complicated than what they are.
Tags (comma-separated)
Save Edits
Cancel