//creando la clase pila
var Stack = function(size) {
this.Size = size;
this.Stacker = new Array(size);
this.pointer = 0;
//funciones
//inserta a la pila
this.Push = function(cadena) {
if (this.IsFull() == false) {
this.Stacker[this.pointer] = cadena;
this.pointer++;
return true;
} else {
return false;
}
}
//saca de la pila
this.Pop = function() {
if (this.IsEmpty != true) {
this.pointer--;
return this.Stacker[this.pointer];
} else {
return false;
}
}
//esta vacia?
this.IsEmpty = function() {
if (this.pointer == 0) return true;
else return false;
} //esta llena?
this.IsFull = function() {
if (this.pointer == this.Size) return true;
else return false;
}
}
Jorge Hernandez :: http://jorgeluis.com.mx