public override bool Delete(T value) { DoublyNode <T> current = (DoublyNode <T>)base.Head; DoublyNode <T> currentHead = (DoublyNode <T>)base.Head; DoublyNode <T> currentTail = (DoublyNode <T>)base.Tail; while (current != null) { if (current.Element.Equals(value)) { break; } if (currentHead.Element.Equals(value)) { current = currentHead; } if (currentTail.Element.Equals(value)) { current = currentHead; } currentHead = (DoublyNode <T>)currentHead.Next; currentTail = (DoublyNode <T>)currentTail.Previous; } if (current != null) { if (current.Next != null) { ((DoublyNode <T>)current.Next).Previous = current.Previous; } else { Tail = current.Previous; } if (current.Previous != null) { current.Previous.Next = current.Next; } else { Head = (DoublyNode <T>)current.Next; } count--; return(true); } return(false); }
protected override Node <T> CreateNode(T value) { DoublyNode <T> node = new DoublyNode <T>(value); return(node); }