Advertisement
BloodknightStudios

stack.cs

Jun 5th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function Stack::onAdd( %this )
  2. {
  3. %this.len = 0;
  4. }
  5.  
  6. function Stack::push( %this, %val )
  7. {
  8. %this.v[%this.len] = %val;
  9. %this.len++;
  10. }
  11.  
  12. function Stack::pop( %this )
  13. {
  14. if( %this.len == 0 )
  15. {
  16. error( "Stack Underflow." );
  17. return "";
  18. }
  19. %this.len--;
  20. return %this.v[%this.len];
  21. }
  22.  
  23. function Stack::length( %this )
  24. {
  25. return %this.len;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement