日期:2014-05-17 浏览次数:20548 次
<?php class Lnode { public $data; public $next; } class Lists { private $root; function Lists() { $this->root = new Lnode; } function append($v) { $sp =& $this->root; while(! empty($sp)) $sp =& $sp->next; $sp = new Lnode; $sp->data = $v; } function delete($v) { $sp =& $this->root; while(! empty($sp) && $sp->next->data != $v) $sp =& $sp->next; if($sp) $sp->next = $sp->next->next; } } $p = new Lists; $p->append('A'); $p->append('B'); $p->append('C'); print_r($p); $p->delete('B'); print_r($p);