From e44c06c14efb91b1dc56841f7791a2a6dff56986 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Tue, 27 Apr 2004 18:15:00 +0000 Subject: [PATCH] - More examples --- ext/spl/examples/emptyiterator.inc | 37 +++++++++++++++ ext/spl/examples/infiniteiterator.inc | 67 +++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100755 ext/spl/examples/emptyiterator.inc create mode 100755 ext/spl/examples/infiniteiterator.inc diff --git a/ext/spl/examples/emptyiterator.inc b/ext/spl/examples/emptyiterator.inc new file mode 100755 index 00000000000..34b5118e741 --- /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 00000000000..d6488750b6d --- /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