public void AddTail(T value)
        {
            var newNode = new CoolNode(value);

            if (this.Count == 0)
            {
                this._head = this._tail = newNode;
            }
            else
            {
                var oldTail = this._tail;
                oldTail.Next     = newNode;
                newNode.Previous = oldTail;
                this._tail       = newNode;
            }

            this.Count++;
        }
        public void AddHead(T value)
        {
            var newNode = new CoolNode(value);

            if (this.Count == 0)
            {
                this._head = this._tail = newNode;
            }
            else
            {
                var oldHead = this._head;
                oldHead.Previous = newNode;
                newNode.Next     = oldHead;
                this._head       = newNode;
            }

            this.Count++;
        }
        public T RemoveHead()
        {
            this.ValidateIfListIsEmpty();
            var value = this._head.Value;

            if (this._head == this._tail)
            {
                this._head = null;
                this._tail = null;
            }
            else
            {
                var newHead = this._head.Next;
                newHead.Previous = null;
                this._head.Next  = null;
                this._head       = newHead;
            }
            this.Count--;
            return(value);
        }
        public void Remove(T value)
        {
            var currentNode = this._head;

            while (currentNode != null)
            {
                var nodeValue = currentNode.Value;

                if (nodeValue.Equals(value))
                {
                    this.Count--;
                    var prevNode = currentNode.Previous;
                    var nextNode = currentNode.Next;
                    if (prevNode != null)
                    {
                        prevNode.Next = nextNode;
                    }

                    if (nextNode != null)
                    {
                        nextNode.Previous = prevNode;
                    }

                    if (this._head == currentNode)
                    {
                        this._head = nextNode;
                    }

                    if (this._tail == currentNode)
                    {
                        this._tail = prevNode;
                    }
                }
                currentNode = currentNode.Next;
            }
        }
 public void Clear()
 {
     this._head = null;
     this._tail = null;
     this.Count = 0;
 }