双向队列
来源:互联网 发布:复制文件夹 linux 编辑:程序博客网 时间:2024/05/28 15:12
用PHP实现一个双向队列,提示array_unshift,array_shift,array_push,array_pop
class sxdl{
public $arr;function __construct($arr)
{
$this -> arr = $arr;
}
function add($val){ //向尾部添加一个
return array_push($this->arr,$val);
}
function insert($val){ //向头部插入一个
return array_unshift($this->arr,$val);
}
function del($val){ //删除尾部
return array_pop($val);
}
function re($val){ //删除头部
return array_shift($val);
}
}
$arr = [1];
$sxdl=new sxdl($arr);
$sxdl->add(2);
$sxdl->add('a');
//print_r($sxdl->add(2));
var_dump($sxdl);
阅读全文
0 0
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- OpenCV之基本绘图
- 蓝牙4.0BLE抓包(三) – 扫描请求和扫描响应
- 前端笔记一
- 富文本插件推荐
- count(*) 与count(1)与count(主键)
- 双向队列
- 如何更高效的使用 Gradle, 快速build apk
- Intellij IDEA 出现“Usage of API documented as @since 1.6+”的解决办法
- jstl select <c:if test下拉菜单不能被选中!
- java批量导入数据到es中出现数据重复问题解决方案
- 获取安卓点击返回事件
- vue2.0 transition -- 动画使用心得
- 由看雪.Wifi万能钥匙 CTF 2017 第4题分析linux double free及unlinking漏洞
- window.location方法获取URL