Stack.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * A class for creating the stack (LIFO) data structure.
  4. * A modification of the Staple_Data_LinkedList class.
  5. *
  6. * @author Ironpilot
  7. * @copyright Copywrite (c) 2011, STAPLE CODE
  8. *
  9. * This file is part of the STAPLE Framework.
  10. *
  11. * The STAPLE Framework is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Lesser General Public License as published by the
  13. * Free Software Foundation, either version 3 of the License, or (at your option)
  14. * any later version.
  15. *
  16. * The STAPLE Framework is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  19. * more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * along with the STAPLE Framework. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. class Staple_Data_Stack extends Staple_Data_LinkedList
  25. {
  26. /**
  27. * Stack push function
  28. * Alias of Staple_Data_LinkedList::add()
  29. * @param mixed $data
  30. */
  31. public function push($data)
  32. {
  33. $this->add($data);
  34. return $this;
  35. }
  36. /**
  37. * Stack pop function.
  38. * Alias of Staple_Data_LinkedList::remove()
  39. * @return mixed
  40. */
  41. public function pop()
  42. {
  43. return $this->remove();
  44. }
  45. }