Esempio n. 1
0
 public void vaciar()
 {
     this.cabeza = new NodoBtree <T>();
     this.cabeza.setSig(cabeza);
     cabeza.setAnt(cabeza);
     this.tamanio = 0;
 }
Esempio n. 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++;
                }
            }
        }
Esempio n. 3
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));
 }
Esempio n. 4
0
 public Cola()
 {
     this.inicio = new NodoBtree <T>();
     this.inicio.setSig(inicio);
     inicio.setAnt(inicio);
     this.tamanio = 0;
 }
Esempio n. 5
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++;
        }
Esempio n. 6
0
        public void insertarAlFinal(T dato)
        {
            NodoBtree <T> x = new NodoBtree <T>(dato, cabeza, cabeza.getAnt());

            cabeza.getAnt().setSig(x);
            cabeza.setAnt(x);
            this.tamanio++;
        }
Esempio n. 7
0
        public void enColar(T info)
        {
            NodoBtree <T> x = new NodoBtree <T>(info, inicio, inicio.getAnt());

            inicio.getAnt().setSig(x);
            inicio.setAnt(x);
            this.aumentarTamanio();
        }
Esempio n. 8
0
        public String toString()
        {
            String        msj = "";
            NodoBtree <T> c   = this.inicio.getSig();

            while (c != inicio)
            {
                msj += c.getInfo().ToString() + "->";
                c    = c.getSig();
            }
            return(msj);
        }
Esempio n. 9
0
        public String toString()
        {
            String        msj = "";
            NodoBtree <T> p   = tope;

            while (p != null)
            {
                msj += p.getInfo().ToString() + "->";
                p    = p.getSig();
            }
            return(msj);
        }
Esempio n. 10
0
 public void apilar(T info)
 {
     if (this.esVacia())
     {
         this.tope = new NodoBtree <T>(info, null);
     }
     else
     {
         this.tope = new NodoBtree <T>(info, this.tope);
     }
     this.tamanio++;
 }
Esempio n. 11
0
        public int getIndice(int dato)
        {
            int i = 0;

            for (NodoBtree <T> x = this.cabeza.getSig(); x != this.cabeza; x = x.getSig())
            {
                if (x.getInfo().Equals(dato))
                {
                    return(i);
                }
                i++;
            }
            return(-1);
        }
Esempio n. 12
0
        public String toString()
        {
            if (this.esVacia())
            {
                return("Lista Vacia");
            }
            String r = "";

            for (NodoBtree <T> x = this.cabeza.getSig(); x.getInfo() != null; x = x.getSig())
            {
                r += x.getInfo().ToString() + "<->";
            }
            return(r);
        }
Esempio n. 13
0
        private NodoBtree <T> getPos(int i)
        {
            if (i < 0 || i >= this.tamanio)
            {
                Console.WriteLine("Error indice no valido en una Lista Circular Doblemente Enlazada");
                return(null);
            }
            NodoBtree <T> x = cabeza.getSig();

            for (; i-- > 0; x = x.getSig())
            {
                ;
            }
            return(x);
        }
Esempio n. 14
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());
        }
Esempio n. 15
0
 public void set(int i, T dato)
 {
     try
     {
         NodoBtree <T> t = this.getPos(i);
         if (t != null)
         {
             t.setInfo(dato);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Esempio n. 16
0
        public T desapilar()
        {
            if (this.esVacia())
            {
                return(default(T));
            }
            NodoBtree <T> x = this.tope;

            this.tope = tope.getSig();
            this.tamanio--;
            if (tamanio == 0)
            {
                this.tope = null;
            }
            return(x.getInfo());
        }
Esempio n. 17
0
 public T get(int i)
 {
     try
     {
         NodoBtree <T> x = this.getPos(i);
         if (x == null)
         {
             return(default(T));
         }
         return(x.getInfo());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(default(T));
 }
Esempio n. 18
0
 public void vaciar()
 {
     this.tope    = null;
     this.tamanio = 0;
 }
Esempio n. 19
0
 public Pila()
 {
     this.tope    = null;
     this.tamanio = 0;
 }
Esempio n. 20
0
 protected void setInicio(NodoBtree <T> ini)
 {
     this.inicio = ini;
 }
Esempio n. 21
0
 public ListaCD()
 {
     this.cabeza = new NodoBtree <T>();
     this.cabeza.setSig(cabeza);
     cabeza.setAnt(cabeza);
 }