LinkedListNodeDouble.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * A Linked List data structure.
  4. *
  5. * @author Ironpilot
  6. * @copyright Copywrite (c) 2011, STAPLE CODE
  7. *
  8. * This file is part of the STAPLE Framework.
  9. *
  10. * The STAPLE Framework is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Lesser General Public License as published by the
  12. * Free Software Foundation, either version 3 of the License, or (at your option)
  13. * any later version.
  14. *
  15. * The STAPLE Framework is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  18. * more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public License
  21. * along with the STAPLE Framework. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. class Staple_Data_LinkedListNodeDouble extends Staple_Data_LinkedListNode
  24. {
  25. /**
  26. * The previous linked node.
  27. * @var Staple_Data_LinkedListNodeDouble
  28. */
  29. public $prev;
  30. /**
  31. * Constructor
  32. * @param mixed $data
  33. * @param Staple_Data_LinkedListNodeDouble $next
  34. * @param Staple_Data_LinkedListNodeDouble $prev
  35. */
  36. public function __construct($data, Staple_Data_LinkedListNodeDouble $next = NULL, Staple_Data_LinkedListNodeDouble $prev = NULL)
  37. {
  38. //Call the parent constructor
  39. parent::__construct($data,$next);
  40. //Set the previous node pointer
  41. if(isset($prev))
  42. {
  43. $this->setPrev($prev);
  44. }
  45. }
  46. /**
  47. * @return the $prev
  48. */
  49. public function getPrev()
  50. {
  51. return $this->prev;
  52. }
  53. /**
  54. * @param Staple_Data_LinkedListNodeDouble $prev
  55. */
  56. public function setPrev($prev)
  57. {
  58. $this->prev = $prev;
  59. return $this;
  60. }
  61. }