Beispiel #1
0
        public void remove(int value)
        {
            bool isInTheList = false;

            if (start.getInfo() == value)
            {
                if (start.getNext() == null)
                {
                    start       = null;
                    isInTheList = true;
                }
                else
                {
                    NohLista temp = new NohLista();
                    temp = start.getNext();
                    temp.setPrevious(null);
                    start       = temp;
                    isInTheList = true;
                }
            }
            else
            {
                NohLista temp = new NohLista();
                temp = start.getNext();
                for (int i = 0; temp != null; i++)
                {
                    if (temp.getNext() == null && value == end.getInfo())
                    {
                        temp = temp.getPrevious();
                        temp.setNext(null);
                        end         = temp;
                        isInTheList = true;
                        break;
                    }
                    else if (temp.getInfo() == value)
                    {
                        temp.getNext().setPrevious(temp.getPrevious());
                        temp.getPrevious().setNext(temp.getNext());
                        temp        = null;
                        isInTheList = true;
                    }
                    else
                    {
                        temp = temp.getNext();
                    }
                }
            }
            if (!(isInTheList))
            {
                System.Windows.Forms.MessageBox.Show("Digite um número que está presente na lista");
            }
        }
Beispiel #2
0
 public void insetAtEnd(int value)
 {
     if (isEmpthy())
     {
         end   = new NohLista(value);
         start = end;
     }
     else
     {
         NohLista temp = new NohLista(value);
         end.setNext(temp);
         temp.setPrevious(end);
         end = temp;
     }
 }
Beispiel #3
0
 public void insetAtStart(int value)
 {
     if (isEmpthy())
     {
         start = new NohLista(value);
         end   = start;
     }
     else
     {
         NohLista temp = new NohLista(value);
         temp.setNext(start);
         start.setPrevious(temp);
         start = temp;
     }
 }