From: Marcus Boerger Date: Tue, 27 Apr 2004 18:15:00 +0000 (+0000) Subject: - More examples X-Git-Tag: RELEASE_0_1~349 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e44c06c14efb91b1dc56841f7791a2a6dff56986;p=php - More examples --- diff --git a/ext/spl/examples/emptyiterator.inc b/ext/spl/examples/emptyiterator.inc new file mode 100755 index 0000000000..34b5118e74 --- /dev/null +++ b/ext/spl/examples/emptyiterator.inc @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/ext/spl/examples/infiniteiterator.inc b/ext/spl/examples/infiniteiterator.inc new file mode 100755 index 0000000000..d6488750b6 --- /dev/null +++ b/ext/spl/examples/infiniteiterator.inc @@ -0,0 +1,67 @@ +$key) + { + echo "$val=>$key\n"; + } + \endverbatim + */ +class InfiniteIterator implements Iterator +{ + private $it; + + function __construct(Iterator $it) + { + $this->it = $it; + } + + function getInnerIterator() + { + return $this->it; + } + + function rewind() + { + $this->it->rewind(); + } + + function valid() + { + return $this->it->valid(); + } + + function current() + { + return $this->it->current(); + } + + function key() + { + return $this->it->key(); + } + + function next() + { + $this->it->next(); + if (!$this->it->valid()) + { + $this->it->rewind(); + } + } +} + +?> \ No newline at end of file