public void Swap(DoubleLink <T> a, DoubleLink <T> b)
        {
            if (a == b)
            {
                throw new Exception("Cannot Swap!");
            }

            DoubleLink <T> beforeA = a.Previous;
            DoubleLink <T> afterA  = a.Next;

            DoubleLink <T> beforeB = b.Previous;
            DoubleLink <T> afterB  = b.Next;



            b.Delete();
            b.InsertAfter(a);

            a.Delete();
            if (beforeB == null)
            {
                a.InsterBefore(afterB);
            }
            else
            {
                if (afterA == b)
                {
                    a.InsertAfter(b);
                }
                else
                {
                    a.InsertAfter(beforeB);
                }
            }
        }
        public DoubleLink <T> FindBy(T value)
        {
            DoubleLink <T> temp = new DoubleLink <T>(value);

            if (this.Value.Equals(value))
            {
                temp = this;
            }
            return(temp);
        }
            //T IEnumerator<T>.Current => throw new NotImplementedException();

            public bool MoveNext()
            {
                //bool result = _node != null;
                if (_node != null)
                {
                    position++;
                    _node = _node.Next;
                }
                //return result;
                return(position <= number);
            }
 public void InsterBefore(DoubleLink <T> node)
 {
     if (node.Previous == null)
     {
         this.Previous = null;
         this.Next     = node;
         node.Previous = this;
     }
     else
     {
         this.Previous      = node.Previous;
         this.Next          = node;
         node.Previous      = this;
         this.Previous.Next = this;
     }
 }
 public void InsertAfter(DoubleLink <T> node)
 {
     if (node.Next == null)
     {
         node.Next     = this;
         this.Previous = node;
         this.Next     = null;
     }
     else
     {
         this.Next          = node.Next;
         this.Previous      = node;
         node.Next          = this;
         this.Next.Previous = this;
     }
 }
 public void Delete()
 {
     if (this.IsHead && this.IsTail)
     {
         throw new Exception("Cannot delete last node!");
     }
     else if (this.IsTail)
     {
         DoubleLink <T> temp = this.Previous;
         temp.Next = null;
     }
     else if (this.IsHead)
     {
         DoubleLink <T> temp = this.Next;
         temp.Previous = null;
     }
     else
     {
         DoubleLink <T> temp1 = this.Previous;
         DoubleLink <T> temp2 = this.Next;
         temp1.Next     = temp2;
         temp2.Previous = temp1;
     }
 }
 public DoubleLinkIEnumerable(DoubleLink <T> node)
 {
     number++;
     _node    = node;
     position = -1;
 }