From b67ca452c33a595f6f1382e32c441943a343353e Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Fri, 29 Oct 2004 20:58:58 +0000 Subject: [PATCH] - Update docu --- ext/spl/internal/cachingiterator.inc | 42 ++++++++++++++++++ ext/spl/internal/cachingrecursiveiterator.inc | 36 +++++++++++++++- ext/spl/internal/filteriterator.inc | 11 ++++- ext/spl/internal/limititerator.inc | 40 ++++++++++++++++- ext/spl/internal/outeriterator.inc | 17 ++++++-- ext/spl/internal/parentiterator.inc | 27 ++++++++++++ ext/spl/internal/recursiveiterator.inc | 19 ++++++++ .../internal/recursiveiteratoriterator.inc | 43 +++++++++++++++++-- ext/spl/internal/seekableiterator.inc | 13 +++++- 9 files changed, 237 insertions(+), 11 deletions(-) diff --git a/ext/spl/internal/cachingiterator.inc b/ext/spl/internal/cachingiterator.inc index a474131b5c..f1b896d05d 100755 --- a/ext/spl/internal/cachingiterator.inc +++ b/ext/spl/internal/cachingiterator.inc @@ -1,8 +1,23 @@ it = $it; @@ -18,12 +39,16 @@ class CachingIterator implements OuterIterator $this->next(); } + /** Rewind the Iterator + */ function rewind() { $this->it->rewind(); $this->next(); } + /** Forward to the next element + */ function next() { if ($this->valid = $this->it->valid()) { @@ -44,31 +69,45 @@ class CachingIterator implements OuterIterator $this->it->next(); } + /** @return whether teh iterator is valid + */ function valid() { return $this->valid; } + /** @return whether there is one more element + */ function hasNext() { return $this->it->valid(); } + /** @return the current element + */ function current() { return $this->current; } + /** @return the current key + */ function key() { return $this->key; } + /** Aggregate the inner iterator + */ function __call($func, $params) { return call_user_func_array(array($this->it, $func), $params); } + /** @return the string represenatation that was generated for the current + * element + * @throw exception when CIT_CALL_TOSTRING was not specified in constructor + */ function __toString() { if (!$this->flags & CIT_CALL_TOSTRING) { @@ -77,6 +116,9 @@ class CachingIterator implements OuterIterator return $this->strValue; } + /** + * @return The inner iterator + */ function getInnerIterator() { return $this->it; diff --git a/ext/spl/internal/cachingrecursiveiterator.inc b/ext/spl/internal/cachingrecursiveiterator.inc index fc7d9a7220..d731c7a725 100755 --- a/ext/spl/internal/cachingrecursiveiterator.inc +++ b/ext/spl/internal/cachingrecursiveiterator.inc @@ -1,15 +1,38 @@ hasChildren = false; @@ -17,6 +40,9 @@ class CachingRecursiveIterator extends CachingIterator implements RecursiveItera parent::rewind(); } + /** Forward to next element if necessary then an Iterator for the Children + * will be created. + */ function next() { if ($this->hasChildren = $this->it->hasChildren()) { @@ -39,11 +65,19 @@ class CachingRecursiveIterator extends CachingIterator implements RecursiveItera parent::next(); } + /** @return whether the current element has children + * @note The check whether the Iterator for the children can be created was + * already executed. Hence when flag CIT_CATCH_GET_CHILD was given in + * constructor this fucntion returns false so that getChildren does + * not try to access those children. + */ function hasChildren() { return $this->hasChildren; } + /** @return An Iterator for the children + */ function getChildren() { return $this->getChildren; diff --git a/ext/spl/internal/filteriterator.inc b/ext/spl/internal/filteriterator.inc index 73c993af84..c5f27bd47d 100755 --- a/ext/spl/internal/filteriterator.inc +++ b/ext/spl/internal/filteriterator.inc @@ -1,9 +1,18 @@ pos = 0; } + /** Seek to specified position + * @param position offset to seek to (relative to beginning not offset + * specified in constructor). + * @throw exception when position is invalid + */ function seek($position) { if ($position < $this->offset) { throw new exception('Cannot seek to '.$position.' which is below offset '.$this->offset); @@ -39,6 +64,8 @@ class LimitIterator implements OuterIterator } } + /** Rewind to offset specified in constructor + */ function rewind() { $this->it->rewind(); @@ -46,24 +73,35 @@ class LimitIterator implements OuterIterator $this->seek($this->offset); } + /** @return whether iterator is valid + */ function valid() { return ($this->count == -1 || $this->pos < $this->offset + $this->count) && $this->it->valid(); } + /** @return current key + */ function key() { return $this->it->key(); } + /** @return current element + */ function current() { return $this->it->current(); } + /** Forward to nect element + */ function next() { $this->it->next(); $this->pos++; } + /** @return current position relative to zero (not to offset specified in + * constructor). + */ function getPosition() { return $this->pos; } diff --git a/ext/spl/internal/outeriterator.inc b/ext/spl/internal/outeriterator.inc index 0bfad6a589..712212aba3 100755 --- a/ext/spl/internal/outeriterator.inc +++ b/ext/spl/internal/outeriterator.inc @@ -1,11 +1,22 @@ it->hasChildren(); } + /** @return whether the current element has children + */ function hasChildren() { return $this->it->hasChildren(); } + /** @return the ParentIterator for the current elements children + */ function getChildren() { return new ParentIterator($this->it->getChildren()); diff --git a/ext/spl/internal/recursiveiterator.inc b/ext/spl/internal/recursiveiterator.inc index 63523ffad9..3bb0d8d0ff 100755 --- a/ext/spl/internal/recursiveiterator.inc +++ b/ext/spl/internal/recursiveiterator.inc @@ -1,8 +1,27 @@ ait[0] = $it; } - + /** Rewind to top iterator as set in constructor + */ function rewind() { while ($this->count) { @@ -26,6 +48,8 @@ class RecursiveIteratorIterator implements OuterIterator $this->ait[0]->recursed = false; } + /** @return whether iterator is valid + */ function valid() { $count = $this->count; @@ -39,18 +63,24 @@ class RecursiveIteratorIterator implements OuterIterator return false; } + /** @reutrn current key + */ function key() { $it = $this->ait[$this->count]; return $it->key(); } + /** @return current element + */ function current() { $it = $this->ait[$this->count]; return $it->current(); } + /** Forward to next element + */ function next() { while ($this->count) { @@ -83,7 +113,10 @@ class RecursiveIteratorIterator implements OuterIterator } } } - + + /** @return Sub Iterator at given level or if unspecified the current sub + * Iterator + */ function getSubIterator($level = NULL) { if (is_null($level)) { @@ -100,6 +133,8 @@ class RecursiveIteratorIterator implements OuterIterator return $this->it; } + /** @return Current Depth (Number of parents) + */ function getDepth() { return $this->level; diff --git a/ext/spl/internal/seekableiterator.inc b/ext/spl/internal/seekableiterator.inc index 3012155771..2cc5331aa1 100755 --- a/ext/spl/internal/seekableiterator.inc +++ b/ext/spl/internal/seekableiterator.inc @@ -1,6 +1,17 @@