Exemple #1
0
Fichier : list.php Projet : xqy/php
    public function getData()
    {
        if ($this->_head != null) {
            $node = $this->pop();
            while ($node) {
                var_dump($node->value . "\n");
                $node = $this->pop();
            }
        } else {
            return "list is empty!\n";
        }
    }
}
class Node
{
    public $value = null;
    public $next = null;
    public $pre = null;
}
$data = array(100, 4, 5, 6, 4, 7, 89, 5, "100c");
$list = new LinkedList();
foreach ($data as $key => $value) {
    $node = new Node();
    $node->value = $value;
    $list->push($node);
    $arr[$key] = $node;
}
var_dump($arr);
//$list->del($arr[2]);
//var_dump($list);
//$list->getData();