public void print()
        {
            DoublyNode <E> tmp = head;

            while (tmp != null)
            {
                Console.Write(tmp.element + " ");
                tmp = tmp.next;
            }

            Console.WriteLine();
        }
        public void Revers()
        {
            DoublyNode <E> tmpprev = null, tmpcur = head, tmpnext = null;

            while (tmpcur != null)
            {
                tmpnext         = tmpcur.next;
                tmpcur.next     = tmpprev;
                tmpprev         = tmpcur;
                tmpcur.previous = tmpnext;
                tmpcur          = tmpnext;
            }
            head = tmpprev;
        }
 public void addLast(E value)
 {
     if (size == 0)
     {
         DoublyNode <E> newNode = new DoublyNode <E>(value, null, null);
         head = newNode;
         tail = newNode;
     }
     else
     {
         DoublyNode <E> newNode = new DoublyNode <E>(value, null, tail);
         tail.next = newNode;
         tail      = newNode;
     }
     size++;
 }
 public void addFirst(E value)
 {
     if (size == 0)
     {
         DoublyNode <E> newNode = new DoublyNode <E>(value, null, null);
         head = newNode;
         tail = newNode;
     }
     else
     {
         DoublyNode <E> newNode = new DoublyNode <E>(value, head, null);
         head.previous = newNode;
         head          = newNode;
     }
     size++;
 }
        public void Insert(int index, DoublyNode <E> value)
        {
            if (isEmpty())
            {
                Console.WriteLine("LinkedList is empty");
            }
            DoublyNode <E> tmp = head;

            for (int i = 0; i < index; i++)
            {
                tmp = tmp.next;
            }

            value.next     = tmp.next;
            value.previous = tmp;
            size++;
        }
        public void Remove(int index)
        {
            DoublyNode <E> tmp = head;
            DoublyNode <E> tmp1;
            DoublyNode <E> tmp2;


            for (int i = 0; i < index; ++i)
            {
                tmp = tmp.next;
            }

            tmp1          = tmp.next;
            tmp2          = tmp1.next;
            tmp.next      = tmp2;
            tmp2.previous = tmp;
            tmp1          = null;
            size--;
        }