Home > Backend Development > PHP Tutorial > php 双向行列

php 双向行列

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:52:02
Original
911 people have browsed it

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 '
Copy after login
';?>

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why is this ID written like this?
From 1970-01-01 08:00:00
0
0
0
Small question about $this
From 1970-01-01 08:00:00
0
0
0
What's the use of this?
From 1970-01-01 08:00:00
0
0
0
This file demo.mp4
From 1970-01-01 08:00:00
0
0
0
javascript - es6中this
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template