SeekableIterator Interface Reference

seekable iterator More...

Inheritance diagram for SeekableIterator:

Inheritance graph
{ArrayIterator\n|+ ARRAY_AS_PROPS\l+ STD_PROP_LIST\l|+ __construct()\l+ append()\l+ asort()\l+ count()\l+ current()\l+ getArrayCopy()\l+ getFlags()\l+ key()\l+ ksort()\l+ natcasesort()\l+ natsort()\l+ next()\l+ offsetExists()\l+ offsetGet()\l+ offsetSet()\l+ offsetUnset()\l+ rewind()\l+ seek()\l+ setFlags()\l+ uasort()\l+ uksort()\l+ valid()\l}{SplFileObject\n|+ DROP_NEW_LINE\l- $delimiter\l- $enclosure\l- $flags\l- $fname\l- $fp\l- $line\l- $lnum\l- $max_len\l|+ __construct()\l+ __toString()\l+ current()\l+ eof()\l+ fflush()\l+ fgetc()\l+ fgetcsv()\l+ fgets()\l+ fgetss()\l+ flock()\l+ fpassthru()\l+ fscanf()\l+ fseek()\l+ fstat()\l+ ftell()\l+ ftruncate()\l+ fwrite()\l+ getChildren()\l+ getCsvControl()\l+ getCurrentLine()\l+ getFlags()\l+ getMaxLineLen()\l+ hasChildren()\l+ key()\l+ next()\l+ rewind()\l+ seek()\l+ setCsvControl()\l+ setFlags()\l+ setMaxLineLen()\l+ valid()\l- freeLine()\l- readLine()\l}{Iterator\n||+ current()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{Traversable\n||}{RecursiveArrayIterator\n|- $ref\l|+ getChildren()\l+ hasChildren()\l}{SubClasses\n||+ __construct()\l+ current()\l}
[legend]
Collaboration diagram for SeekableIterator:

Collaboration graph
{Iterator\n||+ current()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{Traversable\n||}
[legend]
List of all members.

Public Member Functions

 current ()
 key ()
 next ()
 rewind ()
 seek ($index)
 valid ()

Detailed Description

seekable iterator

Author:
Marcus Boerger
Version:
1.0
Since:
PHP 5.0
Turns a normal iterator ino a seekable iterator. When there is a way to seek on an iterator LimitIterator can use this to efficiently rewind to offset.

Definition at line 21 of file seekableiterator.inc.


Member Function Documentation

Iterator::current (  )  [inherited]

Return the current element.

Implemented in ArrayIterator, DirectoryIterator, RecursiveDirectoryIterator, SimpleXMLIterator, SubClasses, DbaReader, DirectoryTreeIterator, DualIterator, RecursiveTreeIterator, AppendIterator, CachingIterator, EmptyIterator, < FilterIterator >, IteratorIterator, LimitIterator, RecursiveIteratorIterator, SplFileObject, and SplObjectStorage.

Iterator::key (  )  [inherited]

Return the key of the current element.

Implemented in ArrayIterator, DirectoryIterator, RecursiveDirectoryIterator, SimpleXMLIterator, DbaReader, DualIterator, RecursiveTreeIterator, AppendIterator, CachingIterator, EmptyIterator, < FilterIterator >, IteratorIterator, LimitIterator, RecursiveIteratorIterator, SplFileObject, and SplObjectStorage.

Iterator::next (  )  [inherited]

Move forward to next element.

Implemented in ArrayIterator, DirectoryIterator, SimpleXMLIterator, DbaReader, DualIterator, AppendIterator, CachingIterator, EmptyIterator, < FilterIterator >, InfiniteIterator, IteratorIterator, LimitIterator, RecursiveIteratorIterator, SplFileObject, and SplObjectStorage.

Iterator::rewind (  )  [inherited]

Rewind the Iterator to the first element.

Implemented in ArrayIterator, DirectoryIterator, SimpleXMLIterator, DbaReader, DualIterator, RecursiveCompareDualIterator, AppendIterator, CachingIterator, EmptyIterator, < FilterIterator >, IteratorIterator, LimitIterator, NoRewindIterator, RecursiveCachingIterator, RecursiveIteratorIterator, SplFileObject, and SplObjectStorage.

SeekableIterator::seek ( index  ) 

Seek to an absolute position.

Parameters:
$index position to seek to
Returns:
void
The method should throw an exception if it is not possible to seek to the given position. Typically this exception should be of type OutOfBoundsException.
    function seek($index);
        $this->rewind();
        $position = 0;
        while($position < $index && $this->valid()) {
            $this->next();
            $position++;
        }
        if (!$this->valid()) {
            throw new OutOfBoundsException('Invalid seek position');
        }
    }

Implemented in ArrayIterator, and SplFileObject.

Iterator::valid (  )  [inherited]

Check if there is a current element after calls to rewind() or next().

Implemented in ArrayIterator, DirectoryIterator, SimpleXMLIterator, DbaReader, DualIterator, AppendIterator, CachingIterator, EmptyIterator, < FilterIterator >, IteratorIterator, LimitIterator, RecursiveIteratorIterator, SplFileObject, and SplObjectStorage.


The documentation for this interface was generated from the following file:
Generated on Thu Apr 26 01:07:29 2007 for SPL-StandardPHPLibrary by  doxygen 1.5.2