cvs: php-src /ext/spl/examples recursivetreeiterator.inc
| From: | Marcus Boerger | Date: | Thu, 13 Oct 2005 19:45:35 +0000 |
| Subject: | cvs: php-src /ext/spl/examples recursivetreeiterator.inc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-34580@lists.php.net to get a copy of this message | ||
helly Thu Oct 13 15:45:35 2005 EDT
Modified files:
/php-src/ext/spl/examples recursivetreeiterator.inc
Log:
- Add ability to bypass key() surrounding and make that default
http://cvs.php.net/diff.php/php-src/ext/spl/examples/recursivetreeiterator.inc?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/spl/examples/recursivetreeiterator.inc
diff -u php-src/ext/spl/examples/recursivetreeiterator.inc:1.5
php-src/ext/spl/examples/recursivetreeiterator.inc:1.6
--- php-src/ext/spl/examples/recursivetreeiterator.inc:1.5 Sat Oct 8 14:57:16 2005
+++ php-src/ext/spl/examples/recursivetreeiterator.inc Thu Oct 13 15:45:29 2005
@@ -19,6 +19,7 @@
class RecursiveTreeIterator extends RecursiveIteratorIterator
{
const BYPASS_CURRENT = 0x00000004;
+ const BYPASS_KEY = 0x00000008;
private $rit_flags;
@@ -28,7 +29,7 @@
* @param cit_flags flags passed to RecursiveCachingIterator (for hasNext)
* @param mode mode passed to RecursiveIteratoIterator (parent)
*/
- function __construct(RecursiveIterator $it, $rit_flags = 0, $cit_flags =
CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST)
+ function __construct(RecursiveIterator $it, $rit_flags = self::BYPASS_KEY, $cit_flags =
CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST)
{
parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $mode, $rit_flags);
$this->rit_flags = $rit_flags;
@@ -91,7 +92,14 @@
*/
function key()
{
- return $this->getPrefix() . parent::key() . $this->getPostfix();
+ if ($this->rit_flags & self::BYPASS_KEY)
+ {
+ return parent::key();
+ }
+ else
+ {
+ return $this->getPrefix() . parent::key() . $this->getPostfix();
+ }
}
/** Aggregates the inner iterator