Inheritance diagram for LimitIterator:


Public Member Functions | |
| __call ($func, $params) | |
| __construct (Iterator $it, $offset=0, $count=-1) | |
| current () | |
| getInnerIterator () | |
| getPosition () | |
| key () | |
| next () | |
| rewind () | |
| seek ($position) | |
| valid () | |
Private Attributes | |
| $count | |
| $it | |
| $offset | |
| $pos | |
This class uses SeekableIterator::seek() if available and rewind() plus a skip loop otehrwise.
Definition at line 24 of file limititerator.inc.
| LimitIterator::__construct | ( | Iterator $ | it, | |
| $ | offset = 0, |
|||
| $ | count = -1 | |||
| ) |
Construct.
| it | Iterator to limit | |
| offset | Offset to first element | |
| count | Maximum number of elements to show or -1 for all |
Definition at line 37 of file limititerator.inc.
References $count, $it, and $offset.
00038 { 00039 if ($offset < 0) { 00040 throw new exception('Parameter offset must be > 0'); 00041 } 00042 if ($count < 0 && $count != -1) { 00043 throw new exception('Parameter count must either be -1 or a value greater than or equal to 0'); 00044 } 00045 $this->it = $it; 00046 $this->offset = $offset; 00047 $this->count = $count; 00048 $this->pos = 0; 00049 }
| LimitIterator::__call | ( | $ | func, | |
| $ | params | |||
| ) |
Aggregate the inner iterator.
| func | Name of method to invoke | |
| params | Array of parameters to pass to method |
Definition at line 128 of file limititerator.inc.
| LimitIterator::current | ( | ) |
| LimitIterator::getInnerIterator | ( | ) |
Implements OuterIterator.
Definition at line 118 of file limititerator.inc.
| LimitIterator::getPosition | ( | ) |
Definition at line 111 of file limititerator.inc.
| LimitIterator::key | ( | ) |
| LimitIterator::next | ( | ) |
Forward to nect element.
Implements Iterator.
Definition at line 103 of file limititerator.inc.
Referenced by seek().
| LimitIterator::rewind | ( | ) |
Rewind to offset specified in constructor.
Implements Iterator.
Definition at line 75 of file limititerator.inc.
References seek().
00076 { 00077 $this->it->rewind(); 00078 $this->pos = 0; 00079 $this->seek($this->offset); 00080 }
Here is the call graph for this function:

| LimitIterator::seek | ( | $ | position | ) |
Seek to specified position.
| position | offset to seek to (relative to beginning not offset specified in constructor). |
| exception | when position is invalid |
Definition at line 56 of file limititerator.inc.
References next().
Referenced by rewind().
00056 { 00057 if ($position < $this->offset) { 00058 throw new exception('Cannot seek to '.$position.' which is below offset '.$this->offset); 00059 } 00060 if ($position > $this->offset + $this->count && $this->count != -1) { 00061 throw new exception('Cannot seek to '.$position.' which is behind offset '.$this->offset.' plus count '.$this->count); 00062 } 00063 if ($this->it instanceof SeekableIterator) { 00064 $this->it->seek($position); 00065 $this->pos = $position; 00066 } else { 00067 while($this->pos < $position && $this->it->valid()) { 00068 $this->next(); 00069 } 00070 } 00071 }
Here is the call graph for this function:

| LimitIterator::valid | ( | ) |
Implements Iterator.
Definition at line 84 of file limititerator.inc.
00084 { 00085 return ($this->count == -1 || $this->pos < $this->offset + $this->count) 00086 && $this->it->valid(); 00087 }
LimitIterator::$count [private] |
LimitIterator::$it [private] |
LimitIterator::$offset [private] |
LimitIterator::$pos [private] |
Definition at line 29 of file limititerator.inc.
1.5.2