public function dequeue() : \generator { while ($this->count() === 0) { yield; } return parent::dequeue(); }
<?php namespace struct; //数据结构 //栈 $stack = new \splStack(); $stack->push('one'); //入栈 $stack->push('two'); echo $stack->pop(); //出栈 echo $stack->pop(); //队列 $queue = new \splQueue(); $queue->enqueue('three'); //入队 $queue->enqueue('four'); echo $queue->dequeue(); //出队 echo $queue->dequeue(); //(最小)堆 $heap = new \splMinHeap(); $heap->insert('five'); $heap->insert('six'); echo $heap->extract(); echo $heap->extract(); //固定尺寸的数组 $sarr = new \splFixedArray(10); $sarr[0] = 'a'; $sarr[8] = 'c';