Beispiel #1
0
 public void LIST_INSERT_(ListObject x)
 {
     x.next        = nil.next;
     nil.next.prev = x;
     nil.next      = x;
     x.prev        = nil;
 }
Beispiel #2
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            ListObject x = new ListObject((int)numericUpDownLinkedList.Value);

            //linkedlist.LIST_INSERT_(x);
            linkedlist.LIST_INSERT(x);
            numericUpDownLinkedList.Value = numericUpDownLinkedList.Value + 1;
            UpdateLinkedList();
        }
Beispiel #3
0
        //sentinel included functions
        public ListObject LIST_SEARCH_(int k)
        {
            ListObject x = nil.next;

            while ((x != nil) & (x.key != k))
            {
                x = x.next;
            }
            return(x);
        }
Beispiel #4
0
 public void LIST_INSERT(ListObject x)
 {
     x.next = head;
     if (head != null)
     {
         head.prev = x;
     }
     head   = x;
     x.prev = null;
 }
Beispiel #5
0
        //
        public ListObject LIST_SEARCH(int k)
        {
            ListObject x = head;

            while ((x != null) & (x.key != k))
            {
                x = x.next;
            }
            return(x);
        }
Beispiel #6
0
 public void LIST_DELETE(ListObject x)
 {
     if (x.prev != null)
     {
         x.prev.next = x.next;
     }
     else
     {
         head = x.next;
     }
     if (x.next != null)
     {
         x.next.prev = x.prev;
     }
 }
Beispiel #7
0
        private void UpdateLinkedList()
        {
            listBoxLinkedList.Items.Clear();
            comboBoxKeys.Items.Clear();
            //ListObject x = linkedlist.Nil.next;
            //while (x != linkedlist.Nil)
            //{
            //    listBoxLinkedList.Items.Add(x.key);
            //    comboBoxKeys.Items.Add(x.key);
            //    x = x.next;
            //}
            ListObject x = linkedlist.Head;

            while (x != null)
            {
                listBoxLinkedList.Items.Add(x.key);
                comboBoxKeys.Items.Add(x.key);
                x = x.next;
            }
        }
Beispiel #8
0
 public void LIST_DELETE_(ListObject x)
 {
     x.prev.next = x.next;
     x.next.prev = x.prev;
 }
Beispiel #9
0
 public LinkedList()
 {
     head = null;
     nil  = new ListObject(null);
 }
Beispiel #10
0
 public ListObject(int?k)
 {
     prev = null;
     next = null;
     key  = k;
 }