Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -4,5 +4,5 @@ function Stack() {
this.push = function(element) {this.data.push(element)}
this.pop = function() {return this.data.pop()}
this.empty = function() {return this.data.length == 0}
this.peek = function() {return this.data[0]}
this.peek = function() {return this.data[this.data.length - 1]}
}

View file

@ -0,0 +1,24 @@
function makeStack() {
var stack = [];
var popStack = function () {
return stack.pop();
};
var pushStack = function () {
return stack.push.apply(stack, arguments);
};
var isEmpty = function () {
return stack.length === 0;
};
var peekStack = function () {
return stack[stack.length-1];
};
return {
pop: popStack,
push: pushStack,
isEmpty: isEmpty,
peek: peekStack,
top: peekStack
};
}