SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var StackedStacks = function(){
  2.   this.stackArray = [];
  3.   this.maxSize = 2;
  4. }
  5.  
  6. StackedStacks.prototype.push = function (data){
  7.  
  8.   var stackIndex = this.stackArray.length - 1;
  9.   var currStack = this.stackArray[stackIndex];
  10.  
  11.   if (stackIndex == -1 || (currStack.size >= this.maxSize)){
  12.     var stack = new Stack();
  13.     stack.push(data);
  14.     this.stackArray.push(stack);
  15.   }
  16.   else{
  17.     currStack.push(data);
  18.     this.stackArray[stackIndex] = currStack;
  19.   }
  20.  
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top