[PHP-CVS] cvs: php-src /ext/spl/examples dualiterator.inc

2009-02-03 Thread Etienne Kneuss
colder  Tue Feb  3 12:40:01 2009 UTC

  Modified files:  
/php-src/ext/spl/examples   dualiterator.inc 
  Log:
  Fix #47031 (Fix constants in example)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/examples/dualiterator.inc?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/spl/examples/dualiterator.inc
diff -u php-src/ext/spl/examples/dualiterator.inc:1.4 
php-src/ext/spl/examples/dualiterator.inc:1.5
--- php-src/ext/spl/examples/dualiterator.inc:1.4   Sun Dec 10 23:44:35 2006
+++ php-src/ext/spl/examples/dualiterator.inc   Tue Feb  3 12:40:00 2009
@@ -23,10 +23,9 @@
 
const KEY_LHS   = 0x10;
const KEY_RHS   = 0x20;
-   const KEY_ARRAY = 0x30;
const KEY_0 = 0x00;

-   const DEFAULT_FLAGS = 0x33;
+   const DEFAULT_FLAGS = 0x13;

private $lhs;
private $rhs;
@@ -39,7 +38,7 @@
 * @param flags iteration flags
 */
function __construct(Iterator $lhs, Iterator $rhs, 
-   $flags = 0x33 
/*DualIterator::DEFAULT_FLAGS*/)
+   $flags = 0x13 
/*DualIterator::DEFAULT_FLAGS*/)
{
$this->lhs   = $lhs;
$this->rhs   = $rhs;
@@ -107,20 +106,18 @@
}
}
 
-   /** @return current value depending on KEY_* flags
+   /** @return key value depending on KEY_* flags
 */ 
function key()
{
switch($this->flags & 0xF0)
{
default:
-   case self::CURRENT_ARRAY:
-   return array($this->lhs->key(), $this->rhs->key());
-   case self::CURRENT_LHS:
+   case self::KEY_LHS:
return $this->lhs->key();
-   case self::CURRENT_RHS:
+   case self::KEY_RHS:
return $this->rhs->key();
-   case self::CURRENT_0:
+   case self::KEY_0:
return NULL;
}
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl/examples dualiterator.inc

2006-12-01 Thread Marcus Boerger
helly   Fri Dec  1 09:28:39 2006 UTC

  Modified files:  
/php-src/ext/spl/examples   dualiterator.inc 
  Log:
  - Fix handling of recursive inner iterators
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/examples/dualiterator.inc?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/spl/examples/dualiterator.inc
diff -u php-src/ext/spl/examples/dualiterator.inc:1.2 
php-src/ext/spl/examples/dualiterator.inc:1.3
--- php-src/ext/spl/examples/dualiterator.inc:1.2   Fri Jul 21 21:54:49 2006
+++ php-src/ext/spl/examples/dualiterator.inc   Fri Dec  1 09:28:38 2006
@@ -12,7 +12,7 @@
 /** @ingroup Examples
  * @brief   Synchronous iteration over two iterators
  * @author  Marcus Boerger
- * @version 1.1
+ * @version 1.2
  */
 class DualIterator implements Iterator
 {
@@ -174,6 +174,7 @@
{
$it = new RecursiveDualIterator($lhs, $rhs, 
self::CURRENT_0 
| self::KEY_0);
+   $it = new RecursiveIteratorIterator($it);
}
else
{
@@ -187,7 +188,7 @@
 
if ($identical)
{
-   foreach(new RecursiveIteratorIterator($it) as $n)
+   foreach($it as $n)
{
if (!$it->areIdentical())
{

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl/examples dualiterator.inc /ext/spl/internal regexiterator.inc

2006-07-21 Thread Marcus Boerger
helly   Fri Jul 21 21:54:49 2006 UTC

  Modified files:  
/php-src/ext/spl/examples   dualiterator.inc 
/php-src/ext/spl/internal   regexiterator.inc 
  Log:
  - Update docu
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/examples/dualiterator.inc?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/examples/dualiterator.inc
diff -u php-src/ext/spl/examples/dualiterator.inc:1.1 
php-src/ext/spl/examples/dualiterator.inc:1.2
--- php-src/ext/spl/examples/dualiterator.inc:1.1   Thu May 25 17:44:59 2006
+++ php-src/ext/spl/examples/dualiterator.inc   Fri Jul 21 21:54:49 2006
@@ -1,6 +1,6 @@
 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/internal/regexiterator.inc?r1=1.7&r2=1.8&diff_format=u
Index: php-src/ext/spl/internal/regexiterator.inc
diff -u php-src/ext/spl/internal/regexiterator.inc:1.7 
php-src/ext/spl/internal/regexiterator.inc:1.8
--- php-src/ext/spl/internal/regexiterator.inc:1.7  Fri Jul 21 19:57:36 2006
+++ php-src/ext/spl/internal/regexiterator.inc  Fri Jul 21 21:54:49 2006
@@ -145,13 +145,6 @@
$this->flags = $flags;
}
 
-   /** @param mode new operaion mode
-*/
-   function setMode($mode)
-   {
-   $this->mode = $mode;
-   }
-
/** @return current PREG flags
 */
function getPregFlags()
@@ -159,7 +152,7 @@
return $this->preg_flags;
}
 
-   /** @param flags new PREG flags
+   /** @param preg_flags new PREG flags
 */
function setPregFlags($preg_flags)
{

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/spl/examples dualiterator.inc recursivedualiterator.inc /ext/spl/examples/tests dualiterator_001.phpt

2006-05-25 Thread Marcus Boerger
helly   Thu May 25 17:44:59 2006 UTC

  Added files: 
/php-src/ext/spl/examples   dualiterator.inc 
recursivedualiterator.inc 
/php-src/ext/spl/examples/tests dualiterator_001.phpt 
  Log:
  - Add DualIterator and RecursiveDualIterator to examples including a test
  
  

http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/examples/dualiterator.inc?view=markup&rev=1.1
Index: php-src/ext/spl/examples/dualiterator.inc
+++ php-src/ext/spl/examples/dualiterator.inc
lhs   = $lhs;
$this->rhs   = $rhs;
$this->flags = $flags;
}

/** @return Left Hand Side Iterator
 */
function getLHS()
{
return $this->lhs;
}

/** @return Right Hand Side Iterator
 */
function getRHS()
{
return $this->rhs;
}

/** @param flags new flags
 */
function setFlags($flags)
{
$this->flags = $flags;
}

/** @return current flags
 */
function getFlags()
{
return $this->flags;
}

/** rewind both inner iterators
 */ 
function rewind()
{
$this->lhs->rewind();
$this->rhs->rewind();   
}

/** @return whether both inner iterators are valid
 */ 
function valid()
{
return $this->lhs->valid() && $this->rhs->valid();  
}

/** @return current value depending on CURRENT_* flags
 */ 
function current()
{
switch($this->flags & 0x0F)
{
default:
case self::CURRENT_ARRAY:
return array($this->lhs->current(), 
$this->rhs->current());
case self::CURRENT_LHS:
return $this->lhs->current();
case self::CURRENT_RHS:
return $this->rhs->current();
case self::CURRENT_0:
return NULL;
}
}

/** @return current value depending on KEY_* flags
 */ 
function key()
{
switch($this->flags & 0xF0)
{
default:
case self::CURRENT_ARRAY:
return array($this->lhs->key(), $this->rhs->key());
case self::CURRENT_LHS:
return $this->lhs->key();
case self::CURRENT_RHS:
return $this->rhs->key();
case self::CURRENT_0:
return NULL;
}
}

/** move both inner iterators forward
 */ 
function next()
{
$this->lhs->next();
$this->rhs->next();
}

/** @return whether both inner iterators are valid and have identical 
 * current and key values or both are non valid.
 */
function areIdentical()
{
return $this->valid()
 ? $this->lhs->current() === $this->rhs->current()
&& $this->lhs->key() === $this->rhs->key()
 : $this->lhs->valid()   ==  $this->rhs->valid();
}

/** @return whether both inner iterators are valid and have equal 
current 
 * and key values or both are non valid.
 */
function areEqual()
{
return $this->valid()
 ? $this->lhs->current() ==  $this->rhs->current()
&& $this->lhs->key() ==  $this->rhs->key()
 : $this->lhs->valid()   ==  $this->rhs->valid();
}

/** Compare two iterators
 *
 * @param lhs   Left  Hand Side Iterator
 * @param rhs   Right Hand Side Iterator
 * @param identical whether to use areEqual() or areIdentical()
 * @return whether both iterators are equal/identical
 *
 * @note If one implements RecursiveIterator the other must do as well.
 *   And if both do then a recursive comparison is being used.
 */
static function compareIterators(Iterator $lhs, Iterator $rhs, 
 $identical = false)
{
if ($lhs instanceof RecursiveIterator)
{
if ($rhs instanceof RecursiveIterator)
{
$it = new RecursiveDualIterator($lhs, $rhs, 
self::CURRENT_0 
| self::KEY_0);
}
else
{
return false;
}
}
else