diff options
| author | Marcus Boerger <helly@php.net> | 2004-05-08 12:35:21 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2004-05-08 12:35:21 +0000 |
| commit | c7b2568269b18105d4940eafe3526c5ae4ba7c54 (patch) | |
| tree | b2a35934aa5b43c28ce9ee6aec70f1ef5ab61640 /ext/spl/examples/appenditerator.inc | |
| parent | 629a25643c61cf6d561c8971c39ba0ef06f87a6b (diff) | |
| download | php-git-c7b2568269b18105d4940eafe3526c5ae4ba7c54.tar.gz | |
- Docu updates
- Add missing example file
- Fix aggregation of inner iterators in examples
Diffstat (limited to 'ext/spl/examples/appenditerator.inc')
| -rwxr-xr-x | ext/spl/examples/appenditerator.inc | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/ext/spl/examples/appenditerator.inc b/ext/spl/examples/appenditerator.inc index df24869755..edc80410df 100755 --- a/ext/spl/examples/appenditerator.inc +++ b/ext/spl/examples/appenditerator.inc @@ -1,30 +1,40 @@ <?php -/** +/** \ingroup Examples * @brief Iterator that iterates over several iterators one after the other * @author Marcus Boerger * @version 1.0 - * */ class AppendIterator implements Iterator { - protected $iterators; + /** @internal array of inner iterators */ + private $iterators; + /** Construct an empty AppendIterator + */ function __construct() { $this->iterators = new ArrayIterator(); } - + + /** Append an Iterator + * @param $it Iterator to append + */ function append(Iterator $it) { $this->iterators->append($it); } + /** @return the current inner Iterator + */ function getInnerIterator() { return $this->iterators->current(); } + /** Rewind to the first element of the first inner Iterator. + * @return void + */ function rewind() { $this->iterators->rewind(); @@ -34,11 +44,15 @@ class AppendIterator implements Iterator } } + /** @return whether the current element is valid + */ function valid() { return $this->iterators->valid() && $this->getInnerIterator()->valid(); } + /** @return the current value if it is valid or \c NULL + */ function current() { /* Using $this->valid() would be exactly the same; it would omit @@ -48,11 +62,17 @@ class AppendIterator implements Iterator return $this->iterators->valid() ? $this->getInnerIterator()->current() : NULL; } + /** @return the current key if it is valid or \c NULL + */ function key() { return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL; } - + + /** Move to the next element. If this means to another Iterator that + * rewind that Iterator. + * @return void + */ function next() { if (!$this->iterators->valid()) @@ -75,6 +95,13 @@ class AppendIterator implements Iterator $this->iterators->next(); } } + + /** Aggregates the inner iterator + */ + function __call($func, $params) + { + return call_user_func_array(array($this->getInnerIterator(), $func), $params); + } } ?>
\ No newline at end of file |
