Home>Article>Backend Development> PHP two-way queue code

PHP two-way queue code

不言
不言 Original
2018-07-04 16:49:30 1285browse

This article mainly introduces the PHP two-way queue, which has certain reference value. Now I share it with you. Friends in need can refer to it.

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); } }

The above is the entire content of this article. I hope it will be helpful to everyone. Learning is helpful. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to generate a short connection in php

##How to use PHP to duration based on seconds

The above is the detailed content of PHP two-way queue code. For more information, please follow other related articles on the PHP Chinese website!

php
Statement:
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