var Stack = function(MAXSIZE) {
this.MAXSIZE = MAXSIZE;
this.InitStack();
};
Stack.prototype = {
Stack: function() {
this.data = new Array(this.MAXSIZE);
this.top = 0;
},
InitStack: function() {
this.S = new this.Stack();
},
ClearStack: function() {
this.S = new Array(this.MAXSIZE);
},
StackEmpty: function() {
return this.S.top == -1 ? true : false;
},
GetTop: function() {
if (this.S.top == -1) return false;
return this.S.data[this.S.top];
},
Push: function(e) {
if (this.S.top == this.MAXSIZE - 1) return false;
this.S.top++;
this.S.data[this.S.top] = e;
return true;
},
Pop: function() {
if (this.S.top == -1) return false;
this.S.top--;
},
StackLength: function() {
return this.S.top;
}
};
window.onload = function() {
var S = new Stack(10);
S.Push(1);
S.Push(2);
S.Pop();
S.Push(3);
S.Pop();
var t = S.GetTop();
console.log(t); //1
}