Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var StackedStacks = function(){
- this.stackArray = [];
- this.maxSize = 2;
- }
- StackedStacks.prototype.push = function (data){
- var stackIndex = this.stackArray.length - 1;
- var currStack = this.stackArray[stackIndex];
- if (stackIndex == -1 || (currStack.size >= this.maxSize)){
- var stack = new Stack();
- stack.push(data);
- this.stackArray.push(stack);
- }
- else{
- currStack.push(data);
- this.stackArray[stackIndex] = currStack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement