示例#1
0
 public void LIST_INSERT_(ListObject x)
 {
     x.next        = nil.next;
     nil.next.prev = x;
     nil.next      = x;
     x.prev        = nil;
 }
示例#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();
        }
示例#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);
        }
示例#4
0
 public void LIST_INSERT(ListObject x)
 {
     x.next = head;
     if (head != null)
     {
         head.prev = x;
     }
     head   = x;
     x.prev = null;
 }
示例#5
0
        //
        public ListObject LIST_SEARCH(int k)
        {
            ListObject x = head;

            while ((x != null) & (x.key != k))
            {
                x = x.next;
            }
            return(x);
        }
示例#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;
     }
 }
示例#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;
            }
        }
示例#8
0
 public void LIST_DELETE_(ListObject x)
 {
     x.prev.next = x.next;
     x.next.prev = x.prev;
 }
示例#9
0
 public LinkedList()
 {
     head = null;
     nil  = new ListObject(null);
 }
示例#10
0
 public ListObject(int?k)
 {
     prev = null;
     next = null;
     key  = k;
 }