public void Clear() { SuperLinkedListNode<T> current = head; while (current != null) { SuperLinkedListNode<T> temp = current; current = current.Next; // use Next the instead of "next", otherwise it will loop forever temp.Invalidate(); } head = null; count = 0; version++; }
internal void InternalRemoveNode(SuperLinkedListNode <T> node) { Debug.Assert(node.list == this, "Deleting the node from another list!"); Debug.Assert(head != null, "This method shouldn't be called on empty list!"); if (node.next == node) { Debug.Assert(count == 1 && head == node, "this should only be true for a list with only one node"); head = null; } else { node.next.prev = node.prev; node.prev.next = node.next; if (head == node) { head = node.next; } } node.Invalidate(); count--; version++; }