public void EnumerateWithRemoval(Func <T, bool> shouldRemove) { LListNode <T> lastNode = null; LListNode <T> currNode = First; while (currNode != null) { if (shouldRemove(currNode.Value)) { if (lastNode == null) { First = currNode.Next; } else { lastNode = currNode.Next; } } else { lastNode = currNode; } currNode = currNode.Next; } }
public LListNode(T value, LListNode <T> next) { Value = value; Next = next; }
public void AddFirst(T value) { First = new LListNode <T>(value, First); }