From: Marcus Boerger Date: Fri, 8 Oct 2004 21:12:15 +0000 (+0000) Subject: Use OuterIterator to simplify conversion to C code X-Git-Tag: PRE_NEW_VM_GEN_PATCH~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5832635b68d167a0615c9246fed0386a600bf34f;p=php Use OuterIterator to simplify conversion to C code --- diff --git a/ext/spl/examples/appenditerator.inc b/ext/spl/examples/appenditerator.inc index d2d5c8dd0b..d9edebc123 100755 --- a/ext/spl/examples/appenditerator.inc +++ b/ext/spl/examples/appenditerator.inc @@ -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; diff --git a/ext/spl/examples/directoryfilterdots.inc b/ext/spl/examples/directoryfilterdots.inc index 899ae6a5d6..abad283234 100755 --- a/ext/spl/examples/directoryfilterdots.inc +++ b/ext/spl/examples/directoryfilterdots.inc @@ -31,28 +31,28 @@ class DirectoryFilterDots extends FilterIterator implements RecursiveIterator */ 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(); } } diff --git a/ext/spl/examples/infiniteiterator.inc b/ext/spl/examples/infiniteiterator.inc index 5f27633eb3..7ff9d4472b 100755 --- a/ext/spl/examples/infiniteiterator.inc +++ b/ext/spl/examples/infiniteiterator.inc @@ -29,7 +29,7 @@ } \endverbatim */ -class InfiniteIterator implements Iterator +class InfiniteIterator implements OuterIterator { /** @internal * The inner Iterator. */ @@ -55,28 +55,28 @@ class InfiniteIterator implements Iterator */ 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 @@ class InfiniteIterator implements Iterator */ 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 @@ class InfiniteIterator implements Iterator */ function __call($func, $params) { - return call_user_func_array(array($this->it, $func), $params); + return call_user_func_array(array($this->getInnerIterator(), $func), $params); } } diff --git a/ext/spl/examples/norewinditerator.inc b/ext/spl/examples/norewinditerator.inc index 6564e1d53e..cdd030c990 100755 --- a/ext/spl/examples/norewinditerator.inc +++ b/ext/spl/examples/norewinditerator.inc @@ -15,7 +15,7 @@ * @version 1.0 * */ -class NoRewindIterator implements Iterator +class NoRewindIterator implements OuterIterator { protected $it; @@ -31,22 +31,27 @@ class NoRewindIterator implements Iterator 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; } }