diff options
Diffstat (limited to 'ext/spl/examples/recursiveiteratoriterator.inc')
-rwxr-xr-x | ext/spl/examples/recursiveiteratoriterator.inc | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/ext/spl/examples/recursiveiteratoriterator.inc b/ext/spl/examples/recursiveiteratoriterator.inc deleted file mode 100755 index b48efb2b3b..0000000000 --- a/ext/spl/examples/recursiveiteratoriterator.inc +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -/** - * @brief Iterates through recursive iterators - * @author Marcus Boerger - * @version 1.0 - * - */ -class RecursiveIteratorIterator implements Iterator -{ - protected $ait = array(); - protected $count = 0; - - function __construct(RecursiveIterator $it) - { - $this->ait[0] = $it; - } - - - function rewind() - { - while ($this->count) { - unset($this->ait[$this->count--]); - } - $this->ait[0]->rewind(); - $this->ait[0]->recursed = false; - } - - function hasMore() - { - $count = $this->count; - while ($count) { - $it = $this->ait[$count]; - if ($it->hasMore()) { - return true; - } - $count--; - } - return false; - } - - function key() - { - $it = $this->ait[$this->count]; - return $it->key(); - } - - function current() - { - $it = $this->ait[$this->count]; - return $it->current(); - } - - function next() - { - while ($this->count) { - $it = $this->ait[$this->count]; - if ($it->hasMore()) { - if (!$it->recursed && $it->hasChildren()) { - $it->recursed = true; - $sub = $it->getChildren(); - $sub->recursed = false; - $sub->rewind(); - if ($sub->hasMore()) { - $this->ait[++$this->count] = $sub; - if (!$sub instanceof RecursiveIterator) { - throw new Exception(get_class($sub).'::getChildren() must return an object that implements RecursiveIterator'); - } - return; - } - unset($sub); - } - $it->next(); - $it->recursed = false; - if ($it->hasMore()) { - return; - } - $it->recursed = false; - } - if ($this->count) { - unset($this->ait[$this->count--]); - $it = $this->ait[$this->count]; - } - } - } - - function getSubIterator($level = NULL) - { - if (is_null($level)) { - $level = $this->count; - } - return @$this->ait[$level]; - } - - function getDepth() - { - return $this->level; - } -} - -?>
\ No newline at end of file |