private void BTN_OverWrite_Click(object sender, EventArgs e) { if (!CheckInputBeingValid(TXT_NewEle.Text, TXT_NewVal.Text) || !CheckIndexBeingValid(LST_Queue.SelectedIndex)) { return; } QueueElement element = new QueueElement(TXT_NewEle.Text, TXT_NewVal.Text); if (elements.Count == 0) { elements.Add(element); LST_Queue.Items.Add(element); } else { if (!CheckIndexBeingValid(LST_Queue.SelectedIndex)) { return; } elements[LST_Queue.SelectedIndex] = element; LST_Queue.Items[LST_Queue.SelectedIndex] = element; } UpdateFrontThreeElementDisplay(); }
private void BTN_Dequeue_Click(object sender, EventArgs e) { if (!CheckIndexBeingValid(LST_Queue.SelectedIndex)) { return; } QueueElement temp = elements[LST_Queue.SelectedIndex]; txtDeqEle.Text = temp.Element.ToString(); txtDeqVal.Text = temp.Value.ToString(); elements.RemoveAt(LST_Queue.SelectedIndex); LST_Queue.Items.RemoveAt(LST_Queue.SelectedIndex); UpdateFrontThreeElementDisplay(); }