コード例 #1
0
 public T eliminar(int i)
 {
     try
     {
         NodoBtree <T> x;
         if (i == 0)
         {
             x = this.cabeza.getSig();
             this.cabeza.setSig(x.getSig());
             this.cabeza.getSig().setAnt(this.cabeza);
             x.setSig(null);
             x.setAnt(null);
             this.tamanio--;
             return(x.getInfo());
         }
         x = this.getPos(i - 1);
         if (x == null)
         {
             return(default(T));
         }
         NodoBtree <T> y = x.getSig();
         x.setSig(y.getSig());
         y.getSig().setAnt(x);
         y.setSig(null);
         y.setAnt(null);
         this.tamanio--;
         return(y.getInfo());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(default(T));
 }
コード例 #2
0
        public void insertarOrdenado(T info)
        {
            if (this.esVacia())
            {
                this.insertarAlInicio(info);
            }
            else
            {
                NodoBtree <T> x = this.cabeza;
                NodoBtree <T> y = x;
                x = x.getSig();
                while (x != this.cabeza)
                {
                    int rta = Comparable.Comparador(info, x.getInfo());

                    if (rta < 0)
                    {
                        break;
                    }
                    y = x;
                    x = x.getSig();
                }
                if (x == cabeza.getSig())
                {
                    this.insertarAlInicio(info);
                }
                else
                {
                    y.setSig(new NodoBtree <T>(info, x, y));
                    x.setAnt(y.getSig());
                    this.tamanio++;
                }
            }
        }
コード例 #3
0
        public void insertarAlInicio(T dato)
        {
            NodoBtree <T> x = new NodoBtree <T>(dato, cabeza.getSig(), cabeza);

            cabeza.setSig(x);
            x.getSig().setAnt(x);
            this.tamanio++;
        }
コード例 #4
0
        public T deColar()
        {
            if (this.esVacia())
            {
                return(default(T));
            }
            NodoBtree <T> x = this.inicio.getSig();

            this.inicio.setSig(x.getSig());
            x.getSig().setAnt(inicio);
            x.setSig(null);
            x.setAnt(null);
            this.tamanio--;
            return(x.getInfo());
        }