]> granicus.if.org Git - php/commitdiff
Update examples
authorMarcus Boerger <helly@php.net>
Sun, 2 May 2004 22:07:32 +0000 (22:07 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 2 May 2004 22:07:32 +0000 (22:07 +0000)
ext/spl/examples/cachingiterator.inc
ext/spl/examples/cachingrecursiveiterator.inc

index 6a20652341df12fe37605449c8d9483bedf13c2e..ac2476f1f823ac4e99f82ed1cafdfb1fda9305d9 100644 (file)
@@ -8,14 +8,14 @@ class CachingIterator
        protected $it;
        protected $current;
        protected $key;
-       protected $more;
+       protected $valid;
        protected $strValue;
-       protected $getStrVal;
 
        function __construct(Iterator $it, $flags = CIT_CALL_TOSTRING)
        {
                $this->it = $it;
                $this->flags = $flags & (CIT_CALL_TOSTRING|CIT_CATCH_GET_CHILD);
+               $this->next();
        }
 
        function rewind()
@@ -26,7 +26,7 @@ class CachingIterator
        
        function next()
        {
-               if ($this->more = $this->it->valid()) {
+               if ($this->valid = $this->it->valid()) {
                        $this->current = $this->it->current();
                        $this->key = $this->it->key();
                        if ($this->flags & CIT_CALL_TOSTRING) {
@@ -46,7 +46,7 @@ class CachingIterator
        
        function valid()
        {
-               return $this->more;
+               return $this->valid;
        }
 
        function hasNext()
index dfeeea54e7adf67b1056637a84e3162b21c0fb54..fc7d9a72209889c7329180384844265045154914 100644 (file)
@@ -4,13 +4,19 @@ class CachingRecursiveIterator extends CachingIterator implements RecursiveItera
 {
        protected $hasChildren;
        protected $getChildren;
-       protected $catch_get_child;
 
        function __construct(RecursiveIterator $it, $flags = CIT_CALL_TOSTRING)
        {
                parent::__construct($it, $flags);
        }
        
+       function rewind();
+       {
+          $this->hasChildren = false;
+          $this->getChildren = NULL;
+          parent::rewind();
+       }
+
        function next()
        {
                if ($this->hasChildren = $this->it->hasChildren()) {