日期:2011-12-16 浏览次数:20603 次
PHP实现的单链表,如下代码:
- <?php
- //结点类
- class Node{
- private $next = NULL; //下一个结点指针
- private $data = NULL; //数据
- public function Node($data, $next = NULL){
- $this->data = $data;
- $next && $this->next = $next;
- }
- public function getData(){
- return $this->data;
- }
- public function setData($data){
- $this->data = $data;
- }
- public function getNext(){
- return $this->next;
- }
- public function setNext($next){
- $this->next = $next;
- }
- }
- &