用PHP寫(xiě)的這個(gè)雙向隊(duì)列應(yīng)該怎么使用
婷婷同學(xué)_
2018-07-04 09:09:23
TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超13個(gè)贊
<?php class Deque{ private $queue = array(); public function addFirst($item){ return array_unshift($this->queue, $item); } public function addLast($item){ return array_push($this->queue, $item); } public function removeFirst(){ return array_shift($this->queue); } public function removeLast(){ return array_pop($this->queue); } }
舉報(bào)