svn: /phpdoc/en/trunk/reference/spl/ seekableiterator.xml

From: Date: Tue, 07 May 2013 07:13:05 +0000
Subject: svn: /phpdoc/en/trunk/reference/spl/ seekableiterator.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-11229@lists.php.net to get a copy of this message
salathe Tue, 07 May 2013 07:13:05 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=330180 Log: Fixed example code: __construct() is not required by SeekableIterator interface, an Iterator must not automatically rewind, A SeekableIterator should not set its position out of bounds -- Provided by ha kre (hanskrentel@yahoo.de) Changed paths: U phpdoc/en/trunk/reference/spl/seekableiterator.xml Modified: phpdoc/en/trunk/reference/spl/seekableiterator.xml =================================================================== --- phpdoc/en/trunk/reference/spl/seekableiterator.xml 2013-05-07 07:08:00 UTC (rev 330179) +++ phpdoc/en/trunk/reference/spl/seekableiterator.xml 2013-05-07 07:13:05 UTC (rev 330180) @@ -59,7 +59,7 @@ <?php class MySeekableIterator implements SeekableIterator { - private $position = 0; + private $position; private $array = array( "first element", @@ -68,20 +68,18 @@ "fourth element" ); + /* Method required for SeekableIterator interface */ + public function seek($position) { - $this->position = $position; - - if (!$this->valid()) { + if (!isset($this->array[$position]) { throw new OutOfBoundsException("invalid seek position ($position)"); } + + $this->position = $position; } /* Methods required for Iterator interface */ - public function __construct() { - $this->position = 0; - } - public function rewind() { $this->position = 0; }

« previous php.doc.cvs (#11229) next »