Queue.class.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * A class for creating the queue (FIFO) 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_Queue extends Staple_Data_LinkedList
  25. {
  26. /**
  27. * Queue shift function adds to the end of the queue.
  28. * Alias of Staple_Data_LinkedList::addBack()
  29. * @param mixed $data
  30. */
  31. public function shift($data)
  32. {
  33. $this->addBack($data);
  34. return $this;
  35. }
  36. /**
  37. * Queue unshift function removes and returns the front element of the list.
  38. * Alias of Staple_Data_LinkedList::removeFront()
  39. * @return mixed
  40. */
  41. public function unshift()
  42. {
  43. return $this->removeFront();
  44. }
  45. }