Back to index

php5  5.3.10
Public Member Functions | Protected Member Functions | Private Attributes
FilterIterator Class Reference

Abstract filter for iterators. More...

Inheritance diagram for FilterIterator:
Inheritance graph
[legend]
Collaboration diagram for FilterIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 __construct (Iterator $it)
 Constructs a filter around another iterator.
 rewind ()
 Rewind the inner iterator.
 accept ()
 Accept function to decide whether an element of the inner iterator should be accessible through the Filteriterator.
 next ()
 Move to next element.
 valid ()
 key ()
 current ()
 getInnerIterator ()
 __call ($func, $params)
 Aggregate the inner iterator.

Protected Member Functions

 fetch ()
 Fetch next element and store it.
 __clone ()
 hidden __clone

Private Attributes

 $it

Detailed Description

Abstract filter for iterators.

Author:
Marcus Boerger
Version:
1.1
Since:
PHP 5.0

Instances of this class act as a filter around iterators. In other words you can put an iterator into the constructor and the instance will only return selected (accepted) elements.

The only thing that needs to be done to make this work is implementing method accept(). Typically this invloves reading the current element or key of the inner Iterator and checking whether it is acceptable.

Definition at line 26 of file filteriterator.inc.


Constructor & Destructor Documentation

Constructs a filter around another iterator.

Parameters:
itIterator to filter

Definition at line 35 of file filteriterator.inc.

                                          {
              $this->it = $it;
       }

Member Function Documentation

FilterIterator::__call ( func,
params 
)

Aggregate the inner iterator.

Parameters:
funcName of method to invoke
paramsArray of parameters to pass to method

Reimplemented in SearchIterator.

Definition at line 121 of file filteriterator.inc.

       {
              return call_user_func_array(array($this->it, $func), $params);
       }
FilterIterator::__clone ( ) [protected]

hidden __clone

Reimplemented in KeyFilter.

Definition at line 104 of file filteriterator.inc.

                                    {
              // disallow clone 
       }
FilterIterator::accept ( ) [abstract]

Accept function to decide whether an element of the inner iterator should be accessible through the Filteriterator.

Returns:
whether or not to expose the current element of the inner iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, FindFile, KeyFilter, NoCvsDirectory, RegexFindFile, DirectoryFilterDots, ParentIterator, and InvertedRegexIterator.

Here is the caller graph for this function:

Returns:
The current value

Implements Iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, and IniGroups.

Definition at line 97 of file filteriterator.inc.

                          {
              return $this->it->current();
       }

Here is the caller graph for this function:

FilterIterator::fetch ( ) [protected]

Fetch next element and store it.

Returns:
void

Definition at line 61 of file filteriterator.inc.

                                  {
              while ($this->it->valid()) {
                     if ($this->accept()) {
                            return;
                     }
                     $this->it->next();
              };
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
The inner iterator

Implements OuterIterator.

Definition at line 111 of file filteriterator.inc.

       {
              return $this->it;
       }

Here is the caller graph for this function:

Returns:
The current key

Implements Iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, IniGroups, and DirectoryFilterDots.

Definition at line 90 of file filteriterator.inc.

                      {
              return $this->it->key();
       }

Here is the caller graph for this function:

Move to next element.

Returns:
void

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 75 of file filteriterator.inc.

                       {
              $this->it->next();
              $this->fetch();
       }

Here is the call graph for this function:

Rewind the inner iterator.

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 42 of file filteriterator.inc.

                         {  
              $this->it->rewind();
              $this->fetch();
       }

Here is the call graph for this function:

Returns:
Whether more elements are available

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 83 of file filteriterator.inc.

                        {
              return $this->it->valid();
       }

Member Data Documentation

Definition at line 28 of file filteriterator.inc.


The documentation for this class was generated from the following file: