php 双向行列

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBasal
2016-06-13 11:52:02913semak imbas

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 '
';?>

?

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn