首頁 >後端開發 >php教程 >php 双向行列

php 双向行列

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-13 11:52:02912瀏覽

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 class="brush:php;toolbar:false">';print_r($fruit);echo '
';?>

?

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn