标签:push first last pre queue add fun ram public
<?php class Deque{ public $queue = array(); /** * 尾部入对 * @param [type] $value [description] */ public function addLast($value){ return array_push($this->queue,$value); } /** * 尾部出队 * @return [type] [description] */ public function removeLast(){ return array_pop($this->queue); } /** * 头部入队 * @param [type] $value [description] */ public function addFirst($value){ return array_unshift($this->queue, $value); } /** * 头部出队 * @return [type] [description] */ public function removeFirst(){ return array_shift($this->queue); } /** * 清空队列 * @return [type] [description] */ public function makeEmpty(){ unset($this->queue); } /** * 获取列头 * @return [type] [description] */ public function getFirst(){ return reset($this->queue); } /** * 获取列尾 * @return [type] [description] */ public function getLast(){ return end($this->queue); } /** * 获取长度 * @return [type] [description] */ public function getLength(){ return count($this->queue); } }
标签:push first last pre queue add fun ram public
原文地址:https://www.cnblogs.com/wangfenphph2/p/9261215.html