SPL-StandardPHPLibrary
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SearchIterator Class Reference
Inheritance diagram for SearchIterator:
Inheritance graph
Collaboration diagram for SearchIterator:
Collaboration graph

Public Member Functions

 __call ($func, $params)
 
 accept ()
 
 current ()
 
 getInnerIterator ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Member Functions

 __clone ()
 
 fetch ()
 

Private Attributes

 $done = false
 

Detailed Description

Iterator to search for a specific element.

Author
Marcus Boerger
Version
1.0

This extended FilterIterator stops after finding the first acceptable value.

Definition at line 20 of file searchiterator.inc.

Member Function Documentation

SearchIterator::__call (   $func,
  $params 
)

Aggregates the inner iterator.

Definition at line 52 of file searchiterator.inc.

References FilterIterator\getInnerIterator().

53  {
54  return call_user_func_array(array($this->getInnerIterator(), $func), $params);
55  }

Here is the call graph for this function:

FilterIterator::__clone ( )
protectedinherited

hidden __clone

Definition at line 104 of file filteriterator.inc.

104  {
105  // disallow clone
106  }
FilterIterator::accept ( )
abstractinherited

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.

Referenced by FilterIterator\fetch().

FilterIterator::current ( )
inherited
Returns
The current value

Implements Iterator.

Definition at line 97 of file filteriterator.inc.

Referenced by RegexFindFile\accept(), and FindFile\accept().

97  {
98  return $this->it->current();
99  }
FilterIterator::fetch ( )
protectedinherited

Fetch next element and store it.

Returns
void

Definition at line 61 of file filteriterator.inc.

References FilterIterator\accept().

Referenced by FilterIterator\next(), and FilterIterator\rewind().

61  {
62  while ($this->it->valid()) {
63  if ($this->accept()) {
64  return;
65  }
66  $this->it->next();
67  };
68  }
accept()
Accept function to decide whether an element of the inner iterator should be accessible through the F...

Here is the call graph for this function:

FilterIterator::getInnerIterator ( )
inherited
FilterIterator::key ( )
inherited
Returns
The current key

Implements Iterator.

Definition at line 90 of file filteriterator.inc.

Referenced by KeyFilter\accept().

90  {
91  return $this->it->key();
92  }
SearchIterator::next ( )

Do not move forward but instead mark as finished.

Returns
void

Implements Iterator.

Definition at line 45 of file searchiterator.inc.

46  {
47  $this->done = true;
48  }
SearchIterator::rewind ( )

Rewind and reset so that it once again searches.

Returns
void

Implements Iterator.

Definition at line 28 of file searchiterator.inc.

29  {
30  parent::rewind();
31  $this->done = false;
32  }
SearchIterator::valid ( )
Returns
whether the current element is valid which can only happen once per iteration.

Implements Iterator.

Definition at line 37 of file searchiterator.inc.

38  {
39  return !$this->done && parent::valid();
40  }

Member Data Documentation

SearchIterator::$done = false
private

whether an entry was found already

Definition at line 23 of file searchiterator.inc.


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