时间:2021-07-01 10:21:17 帮助过:12人阅读
栈的实现
$stack = new SplStack(); //入栈 $stack->push('a'); $stack->push('b'); //出栈 echo $stack->pop(); echo $stack->pop();
队列的实现
$queue = new SplQueue(); //入队列 $queue->enqueue('a'); $queue->enqueue('b'); $queue->enqueue('c'); //出队列 echo $queue->dequeue(); echo $queue->dequeue(); echo $queue->dequeue();
最小堆的实现
$heap = new SplMinHeap(); //插入到堆 $heap->insert('a'); $heap->insert('b'); //从堆中提取数据 echo $heap->extract(); echo $heap->extract();
固定长度的数组
$array = new SplFixedArray(5); $array[1] = 5; var_dump($array);