Пример #1
0
        public void InsertATbetween(int inputval, int beforeValue)
        {
            bool flag = false; D_Node temp = start.next;

            while (temp.next != null)
            {
                if (temp.data == beforeValue)
                {
                    if (temp.next == null)
                    {
                        insertAtEnd(inputval); flag = true; break;
                    }
                    else
                    {
                        D_Node n = new D_Node(inputval);
                        n.next        = temp.next;
                        n.pre         = temp;
                        temp.next.pre = n;
                        temp.next     = n;
                        flag          = true; break;
                    }
                }
                else
                {
                    temp = temp.next;
                }
            }
        }
Пример #2
0
        public D_Node DeleteFrom(int val)
        {
            D_Node n = null; bool IS_DEL = false;
            D_Node temp = start.next;

            while (temp.next != null)
            {
                if (temp.data == val)
                {
                    if (temp.next == end.pre)
                    {
                        n = temp.next; DeleteEnd(); IS_DEL = true; break;
                    }
                    else
                    {
                        n             = temp.next;
                        temp.next     = temp.next.next;
                        temp.next.pre = n.pre; IS_DEL = true; break;
                    }
                }
                else
                {
                    temp = temp.next;
                }
            }

            return(n);
        }
Пример #3
0
        public void Display(DC_LinkedList li)
        {
            D_Node temp = start.next;

            while (temp.next != start.next)
            {
                Console.WriteLine(temp.data);
                temp = temp.next;
            }
            Console.WriteLine(temp.data);
        }
Пример #4
0
 public void insertAtEnd(int val)
 {
     if (start.next == null)
     {
         D_Node n = new D_Node(val);
         start.next = n;
         end.pre    = n; end.next = start.next;
         n.next     = start.next;
     }
     else
     {
         D_Node n = new D_Node(val);
         end.pre.next = n;
         n.pre        = end.pre;
         end.pre      = n; end.next = start.next;
         n.next       = start.next;
     }
 }
Пример #5
0
        public void inserAtBegng(int val)
        {
            if (start.next == null)
            {
                D_Node n = new D_Node(val);
                start.next = n;
                end.pre    = n; end.next = start.next;
                n.next     = start.next;
            }
            else

            {
                D_Node temp;
                D_Node n = new D_Node(val);
                n.next     = start.next;
                temp       = start.next;
                temp.pre   = n;
                start.next = n;
                end.next   = start.next;
                n.next     = start.next;
            }
        }
Пример #6
0
 public D_Node()
 {
     next = null;
     data = 0;
 }