cvs: php-src /ext/spl/examples appenditerator.inc directoryfilterdots.inc infiniteiterator.inc norewinditerator.inc
| From: | Marcus Boerger | Date: | Fri, 08 Oct 2004 21:12:16 +0000 |
| Subject: | cvs: php-src /ext/spl/examples appenditerator.inc directoryfilterdots.inc infiniteiterator.inc norewinditerator.inc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-28935@lists.php.net to get a copy of this message | ||
helly Fri Oct 8 17:12:16 2004 EDT
Modified files:
/php-src/ext/spl/examples appenditerator.inc
directoryfilterdots.inc
infiniteiterator.inc norewinditerator.inc
Log:
Use OuterIterator to simplify conversion to C code
http://cvs.php.net/diff.php/php-src/ext/spl/examples/appenditerator.inc?r1=1.7&r2=1.8&ty=u
Index: php-src/ext/spl/examples/appenditerator.inc
diff -u php-src/ext/spl/examples/appenditerator.inc:1.7
php-src/ext/spl/examples/appenditerator.inc:1.8
--- php-src/ext/spl/examples/appenditerator.inc:1.7 Mon May 10 13:26:03 2004
+++ php-src/ext/spl/examples/appenditerator.inc Fri Oct 8 17:12:15 2004
@@ -14,7 +14,7 @@
* @author Marcus Boerger
* @version 1.0
*/
-class AppendIterator implements Iterator
+class AppendIterator implements OuterIterator
{
/** @internal array of inner iterators */
private $iterators;
http://cvs.php.net/diff.php/php-src/ext/spl/examples/directoryfilterdots.inc?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/spl/examples/directoryfilterdots.inc
diff -u php-src/ext/spl/examples/directoryfilterdots.inc:1.3
php-src/ext/spl/examples/directoryfilterdots.inc:1.4
--- php-src/ext/spl/examples/directoryfilterdots.inc:1.3 Mon May 10 13:26:03 2004
+++ php-src/ext/spl/examples/directoryfilterdots.inc Fri Oct 8 17:12:15 2004
@@ -31,28 +31,28 @@
*/
function accept()
{
- return !$this->it->isDot();
+ return !$this->getInnerIterator()->isDot();
}
/** @return whether the current entry is a directory
*/
function hasChildren()
{
- return $this->it->hasChildren();
+ return $this->getInnerIterator()->hasChildren();
}
/** @return the current subdirectory as a new DirectoryFilterDots instance.
*/
function getChildren()
{
- return new DirectoryFilterDots($this->it->getPathname());
+ return new DirectoryFilterDots($this->getInnerIterator()->getPathname());
}
/** @return the current entries path name
*/
function key()
{
- return $this->it->getPathname();
+ return $this->getInnerIterator()->getPathname();
}
}
http://cvs.php.net/diff.php/php-src/ext/spl/examples/infiniteiterator.inc?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/spl/examples/infiniteiterator.inc
diff -u php-src/ext/spl/examples/infiniteiterator.inc:1.4
php-src/ext/spl/examples/infiniteiterator.inc:1.5
--- php-src/ext/spl/examples/infiniteiterator.inc:1.4 Mon May 10 13:26:03 2004
+++ php-src/ext/spl/examples/infiniteiterator.inc Fri Oct 8 17:12:15 2004
@@ -29,7 +29,7 @@
}
\endverbatim
*/
-class InfiniteIterator implements Iterator
+class InfiniteIterator implements OuterIterator
{
/** @internal
* The inner Iterator. */
@@ -55,28 +55,28 @@
*/
function rewind()
{
- $this->it->rewind();
+ $this->getInnerIterator()->rewind();
}
/** @return whether the current element is valid
*/
function valid()
{
- return $this->it->valid();
+ return $this->getInnerIterator()->valid();
}
/** @return the current value
*/
function current()
{
- return $this->it->current();
+ return $this->getInnerIterator()->current();
}
/** @return the current key
*/
function key()
{
- return $this->it->key();
+ return $this->getInnerIterator()->key();
}
/** Move the inner Iterator forward to its next element or rewind it.
@@ -84,10 +84,10 @@
*/
function next()
{
- $this->it->next();
- if (!$this->it->valid())
+ $this->getInnerIterator()->next();
+ if (!$this->getInnerIterator()->valid())
{
- $this->it->rewind();
+ $this->getInnerIterator()->rewind();
}
}
@@ -95,7 +95,7 @@
*/
function __call($func, $params)
{
- return call_user_func_array(array($this->it, $func), $params);
+ return call_user_func_array(array($this->getInnerIterator(), $func), $params);
}
}
http://cvs.php.net/diff.php/php-src/ext/spl/examples/norewinditerator.inc?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/spl/examples/norewinditerator.inc
diff -u php-src/ext/spl/examples/norewinditerator.inc:1.2
php-src/ext/spl/examples/norewinditerator.inc:1.3
--- php-src/ext/spl/examples/norewinditerator.inc:1.2 Mon May 10 13:26:03 2004
+++ php-src/ext/spl/examples/norewinditerator.inc Fri Oct 8 17:12:15 2004
@@ -15,7 +15,7 @@
* @version 1.0
*
*/
-class NoRewindIterator implements Iterator
+class NoRewindIterator implements OuterIterator
{
protected $it;
@@ -31,22 +31,27 @@
function valid()
{
- return $this->it->valid();
+ return $this->getInnerIterator()->valid();
}
function current()
{
- return $this->it->current();
+ return $this->getInnerIterator()->current();
}
function key()
{
- return $this->it->key();
+ return $this->getInnerIterator()->key();
}
function next()
{
- $this->it->next();
+ $this->getInnerIterator()->next();
+ }
+
+ function getInnerIterator()
+ {
+ return $this->it;
}
}