6.10 Iterator and SPL Classes and Interfaces

 <  Day Day Up  >  

This chapter demonstrates many classes, abstract classes, and interfaces, yet it only begins to touch on the full nature of SPL.

Table 6-3 is a quick-reference guide to the complete collection of SPL iterators, including some not mentioned in this chapter. For more information, see the SPL section of the PHP Manual at http://www.php.net/spl.

Table 6-3. Iterator and SPL classes and interfaces

Name

Type

Relationship

Description

ArrayObject

Class

Implements IteratorAggregate interface

Converts arrays and objects into iterators

ArrayIterator

Class

Implements Iterator interface

Used by ArrayObject ; cannot be instantiated directly

CachingIterator

Class

Implements Iterator interface

Provides "look ahead by one" capability using hasNext( )

CachingRecursiveIterator

Class

Extends CachingIterator class; implements RecursiveIterator interface

Adds caching support to recursive iterators

DirectoryIterator

Class

Implements Iterator interface

An iterator for directory files

FilterIterator

Abstract class

Implements Iterator interface

Allows filtering of other iterators using accept( ) method

Iterator

Interface

Defines Iterator interface

Implements an iterator

IteratorAggregate

Interface

Defines IteratorAggregate interface

Allows classes to control iteration by returning iterator from getIterator( ) method

LimitIterator

Class

Implements Iterator interface

Emulates database LIMIT clause

ParentIterator

Class

Extends FilterIterator class; implements RecursiveIterator interface

Filters out leaf items, so only parents (items with children) are processed

RecursiveDirectoryIterator

Class

Implements RecursiveIterator interface

A recursive iterator for directory files; goes through all subdirectories

RecursiveIterator

Interface

Extends Iterator interface

Implements a recursive iterator

RecursiveIteratorIterator

Class

Implements Iterator interface

An iterator for classes that implement RecursiveIterator interface

SeekableIterator

Interface

Extends Iterator interface

Adds ability to seek( ) within an iterator; used by LimitIterator class

SimpleXMLIterator

Class

Implements Iterator interface

An iterator for XML files using SimpleXML functions; only iterates over XML text nodes


 <  Day Day Up  >  


Upgrading to PHP 5
Upgrading to PHP 5
ISBN: 0596006365
EAN: 2147483647
Year: 2004
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net