Exemplo n.º 1
0
        public void remove(int data)
        {
            NohFila temp = achaNoh(data);

            if (isEmpty())
            {
                return;
            }

            else if (temp == null)
            {
                return;
            }
            else if (temp == start && temp == end)
            {
                start = end = null;
            }

            else if (temp == start)
            {
                start = start.getNext();
                start.setPrev(null);
            }

            else if (temp == end)
            {
                end = end.getPrev();
                end.setNext(null);
            }
            else
            {
                temp.getPrev().setNext(temp.getNext());
                temp.getNext().setPrev(temp.getPrev());
            }
        }
Exemplo n.º 2
0
        }// Fim da função inserir

        public NohFila achaNoh(int data)
        {
            NohFila temp = start;

            while (temp != end)
            {
                if (temp.getData().Equals(data))
                {
                    break;
                }
                else
                {
                    temp = temp.getNext();
                }
            }
            if (temp == null)
            {
                return(null);
            }
            else if ((temp == end && !(temp.getData().Equals(data))))
            {
                return(null);
            }
            else
            {
                return(temp);
            }
        }
Exemplo n.º 3
0
        public void inserir(int data)
        {
            NohFila novoNoh = new NohFila(data);

            if (isEmpty())
            {
                start = end = novoNoh;
            }

            else
            {
                end.setNext(novoNoh);
                novoNoh.setPrev(end);
                end = novoNoh;
            }
        }// Fim da função inserir
        private void bt4_Click(object sender, EventArgs e)
        {
            tbFila.Clear();
            NohFila temp = minhafila.start;

            if (minhafila.isEmpty())
            {
                tbFila.Clear();
                MessageBox.Show("Não há itens na Fila!", "Fila vazia");
            }

            else
            {
                while (temp != null)
                {
                    tbFila.Text = tbFila.Text + "  " + Convert.ToString(temp.getData());
                    temp        = temp.getNext();
                }
            }
        }
Exemplo n.º 5
0
        public void inserirdps(int data, int depois) //Para a letra C
        {
            NohFila temp   = achaNoh(depois);
            NohFila newnoh = new NohFila(data);

            if (isEmpty())
            {
                start = end = newnoh;
            }
            else if (temp.getNext() == null)
            {
                newnoh.setPrev(temp);
                newnoh.setNext(null);
                temp.setNext(newnoh);
            }
            else
            {
                newnoh.setPrev(temp);
                newnoh.setNext(temp.getNext());
                temp.setNext(newnoh);
                newnoh.getNext().setPrev(newnoh);
            }
        }
 public void setPrev(NohFila noh)
 {
     prev = noh;
 }
 public void setNext(NohFila noh)
 {
     anterior = noh;
 }
 public NohFila(int _data)
 {
     data     = _data;
     anterior = null;
 }
 //métodos
 public NohFila()
 {
     data     = 0;
     anterior = null;
 }
Exemplo n.º 10
0
 //Métodos
 //construtor default
 public Fila()
 {
     start = null;
     end   = null;
 }