用 PHP 实现一个双向队列
class DEQueue { //存储 protected $_storage = array(); //入头 public function unshift($element) { return array_unshift($this->_storage, $element); } //入尾 public function push($element) { return array_push($this->_storage, $element); } //出尾 public function pop() { return array_pop($this->_storage); } //出头 public function shift() { return array_shift($this->_storage); } //长度 public function length() { return count($this->_storage); } }