public void LIST_INSERT_(ListObject x) { x.next = nil.next; nil.next.prev = x; nil.next = x; x.prev = nil; }
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(); }
//sentinel included functions public ListObject LIST_SEARCH_(int k) { ListObject x = nil.next; while ((x != nil) & (x.key != k)) { x = x.next; } return(x); }
public void LIST_INSERT(ListObject x) { x.next = head; if (head != null) { head.prev = x; } head = x; x.prev = null; }
// public ListObject LIST_SEARCH(int k) { ListObject x = head; while ((x != null) & (x.key != k)) { x = x.next; } return(x); }
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; } }
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; } }
public void LIST_DELETE_(ListObject x) { x.prev.next = x.next; x.next.prev = x.prev; }
public LinkedList() { head = null; nil = new ListObject(null); }
public ListObject(int?k) { prev = null; next = null; key = k; }