PHP 迭代器模式 一个简单的迭代器
来源:互联网 发布:jpz45加强后数据105炮 编辑:程序博客网 时间:2024/06/11 14:44
<?phpheader("Content-Type:text/html;charset=utf-8");abstract class llIterator{ // 第一个 public abstract function First(); // 最后一个 public abstract function End(); // 下一个 public abstract function Next(); // 前一个 public abstract function Pre(); // 当前 public abstract function Current(); // 指针返回 public abstract function back();}class Con extends llIterator{ private $any; private $current = 0; public function __construct(array $anys) { $this->any = $anys; } public function First() { $this->current = 0; return $this->any[0]; } public function End() { $this->current = count($this->any) - 1; return $this->any[count($this->any) - 1]; } public function Next() { $this->current++; return $this->any[$this->current]; } public function Pre() { $this->current--; return $this->any[$this->current > 5 ? 4 : $this->current]; } public function Current() { return $this->any[$this->current > 5 ? 4 : $this->current]; } public function back() { $this->current = 0; }}$test = new Con(array('蓝猫','火猫','土猫','大熊猫','龙鹰'));echo $test->First();echo $test->Next();echo $test->End();echo $test->Current();echo $test->Pre();echo $test->back();
阅读全文
0 0
- PHP 迭代器模式 一个简单的迭代器
- PHP的简单工厂模式
- php的一个简单例子
- 一个简单的PHP例子
- 一个简单的PHP分页
- 一个简单的PHP扩展
- 一个简单的Php服务端
- 一个简单的PHP留言板
- 一个简单的工厂模式
- 一个简单的工厂模式
- 一个简单的工厂模式
- 一个简单的MVP模式
- php一个简单的uuid的实现
- PHP实现的一个简单的爬虫
- PHP单子模式(SINGLETON)的简单实现
- 一个简单的php在线端口扫描器
- 一个简单的PHP图形计数器
- 一个简单的php在线端口扫描器
- 1小时复习MySQL(2)
- 剑指offer 链表
- 决策树和随机森林用 python treeinterpreter实现
- gdb 调试c/c++的一些小技巧
- 一部分linux源码和操作系统知识
- PHP 迭代器模式 一个简单的迭代器
- 二叉树的链式存储实现及遍历
- POJ 2823 Sliding Window
- DUC
- activeMQ 消息队列 相关配置
- 分布式资源管理器YARN简介(一)
- C语言的一些概念
- error C2679: binary '<<' : no operator found 解决办法
- 十字链表存储稀疏矩阵