Exemple #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());
            }
        }
Exemple #2
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);
            }
        }
Exemple #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