LinkedListNode.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * Linked List Data Nodes
  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_LinkedListNode
  24. {
  25. /**
  26. * The data contained in the node
  27. * @var mixed
  28. */
  29. public $data;
  30. /**
  31. * Pointer to the next node
  32. * @var Staple_Data_LinkedListNode
  33. */
  34. public $next;
  35. /**
  36. * Constructor to create data and link the node.
  37. * @param mixed $data
  38. * @param Staple_Data_LinkedListNode $next
  39. */
  40. public function __construct($data,$next = null)
  41. {
  42. //Set the data
  43. $this->setData($data);
  44. //Set the next node link
  45. if(isset($next))
  46. {
  47. $this->setNext($next);
  48. }
  49. }
  50. /**
  51. * @return the $data
  52. */
  53. public function getData()
  54. {
  55. return $this->data;
  56. }
  57. /**
  58. * @return Staple_Data_LinkedListNode $next
  59. */
  60. public function getNext()
  61. {
  62. return $this->next;
  63. }
  64. /**
  65. * @param mixed $data
  66. */
  67. public function setData($data)
  68. {
  69. $this->data = $data;
  70. return $this;
  71. }
  72. /**
  73. * @param Staple_Data_LinkedListNode $next
  74. */
  75. public function setNext(Staple_Data_LinkedListNode $next)
  76. {
  77. $this->next = $next;
  78. return $this;
  79. }
  80. }