当前位置: 代码迷 >> PHP >> php 双向行列
  详细解决方案

php 双向行列

热度:50   发布时间:2016-04-28 19:34:13.0
php 双向队列
<?php class deque{	public $queue  = array();	public $length = 0;   	public function frontAdd($node){		array_unshift($this->queue,$node);		$this->countqueue();	}	public function frontRemove(){		$node = array_shift($this->queue);		$this->countqueue();		return $node;	}	  	public function rearAdd($node){		array_push($this->queue,$node);		$this->countqueue();	}	 	public function rearRemove(){		$node = array_pop($this->queue);		$this->countqueue();		return $node;	}	 	public function countqueue(){		$this->length = count($this->queue);    	}}$fruit = new deque();echo $fruit -> length;$fruit -> frontAdd("Apple");$fruit -> rearAdd("Watermelon");echo '<pre>';print_r($fruit);echo '</pre>';?>

?

  相关解决方案