diff options
author | Marcus Boerger <helly@php.net> | 2004-10-31 19:49:18 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2004-10-31 19:49:18 +0000 |
commit | de3a8ea3e132db2c4edc0e2f4b4468fbcced26e8 (patch) | |
tree | 080d5332bc093f30d1fbab3667a71d1d3c39a53d /ext/spl/examples | |
parent | 081dac3026c470aa640aee1fc1645a27a1bf7603 (diff) | |
download | php-git-de3a8ea3e132db2c4edc0e2f4b4468fbcced26e8.tar.gz |
- Implement InfiniteIterator in C
Diffstat (limited to 'ext/spl/examples')
-rwxr-xr-x | ext/spl/examples/infiniteiterator.inc | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/ext/spl/examples/infiniteiterator.inc b/ext/spl/examples/infiniteiterator.inc deleted file mode 100755 index 7ff9d4472b..0000000000 --- a/ext/spl/examples/infiniteiterator.inc +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -/** @file infiniteiterator.inc - * @ingroup Examples - * @brief class InfiniteIterator - * @author Marcus Boerger - * @date 2003 - 2004 - * - * SPL - Standard PHP Library - */ - -/** @ingroup Examples - * @brief An infinite Iterator - * @author Marcus Boerger - * @version 1.0 - * - * This Iterator takes another Iterator and infinitvely iterates it by - * rewinding it when its end is reached. - * - * \note Even an InfiniteIterator stops if its inner Iterator is empty. - * - \verbatim - $it = new ArrayIterator(array(1,2,3)); - $infinite = new InfiniteIterator($it); - $limit = new LimitIterator($infinite, 0, 5); - foreach($limit as $val=>$key) - { - echo "$val=>$key\n"; - } - \endverbatim - */ -class InfiniteIterator implements OuterIterator -{ - /** @internal - * The inner Iterator. */ - private $it; - - /** Construct from another Iterator. - * @param $it the inner Iterator. - */ - function __construct(Iterator $it) - { - $this->it = $it; - } - - /** @return the inner iterator - */ - function getInnerIterator() - { - return $this->it; - } - - /** Rewind the inner iterator. - * @return void - */ - function rewind() - { - $this->getInnerIterator()->rewind(); - } - - /** @return whether the current element is valid - */ - function valid() - { - return $this->getInnerIterator()->valid(); - } - - /** @return the current value - */ - function current() - { - return $this->getInnerIterator()->current(); - } - - /** @return the current key - */ - function key() - { - return $this->getInnerIterator()->key(); - } - - /** Move the inner Iterator forward to its next element or rewind it. - * @return void - */ - function next() - { - $this->getInnerIterator()->next(); - if (!$this->getInnerIterator()->valid()) - { - $this->getInnerIterator()->rewind(); - } - } - - /** Aggregates the inner iterator - */ - function __call($func, $params) - { - return call_user_func_array(array($this->getInnerIterator(), $func), $params); - } -} - -?>
\ No newline at end of file |