colder          Thu May 15 17:05:20 2008 UTC

  Modified files:              
    /php-src/ext/spl    spl_heap.c 
    /php-src/ext/spl/tests      pqueue_001.phpt 
  Log:
  Implement SplPriorityQueue::getExtractFlags()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/spl/spl_heap.c
diff -u php-src/ext/spl/spl_heap.c:1.3 php-src/ext/spl/spl_heap.c:1.4
--- php-src/ext/spl/spl_heap.c:1.3      Fri Feb 29 09:25:30 2008
+++ php-src/ext/spl/spl_heap.c  Thu May 15 17:05:20 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_heap.c,v 1.3 2008/02/29 09:25:30 colder Exp $ */
+/* $Id: spl_heap.c,v 1.4 2008/05/15 17:05:20 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -737,7 +737,7 @@
 }
 /* }}} */
 
-/* {{{ proto int SplPriorityQueue::setIteratorMode($flags) U
+/* {{{ proto int SplPriorityQueue::setExtractFlags($flags) U
  Set the flags of extraction*/
 SPL_METHOD(SplPriorityQueue, setExtractFlags)
 {
@@ -755,6 +755,22 @@
        RETURN_LONG(intern->flags);
 }
 /* }}} */
+/* {{{ proto int SplPriorityQueue::getExtractFlags($flags) U
+ Set the flags of extraction*/
+SPL_METHOD(SplPriorityQueue, getExtractFlags)
+{
+       long value;
+       spl_heap_object *intern;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
+               return;
+       }
+
+       intern = (spl_heap_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
+
+       RETURN_LONG(intern->flags & SPL_PQUEUE_EXTR_MASK;);
+}
+/* }}} */
 
 /* {{{ proto int SplHeap::recoverFromCorruption() U
  Recover from a corrupted state*/
@@ -1119,6 +1135,7 @@
        SPL_ME(SplPriorityQueue, compare,               arginfo_heap_compare,   
 ZEND_ACC_PUBLIC)
        SPL_ME(SplPriorityQueue, insert,                arginfo_pqueue_insert,  
 ZEND_ACC_PUBLIC)
        SPL_ME(SplPriorityQueue, setExtractFlags,       
arginfo_pqueue_setflags, ZEND_ACC_PUBLIC)
+       SPL_ME(SplPriorityQueue, getExtractFlags,       NULL,                   
 ZEND_ACC_PUBLIC)
        SPL_ME(SplPriorityQueue, top,                   NULL,                   
 ZEND_ACC_PUBLIC)
        SPL_ME(SplPriorityQueue, extract,               NULL,                   
 ZEND_ACC_PUBLIC)
        SPL_ME(SplHeap,          count,                 NULL,                   
 ZEND_ACC_PUBLIC)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/pqueue_001.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/pqueue_001.phpt
diff -u php-src/ext/spl/tests/pqueue_001.phpt:1.1 
php-src/ext/spl/tests/pqueue_001.phpt:1.2
--- php-src/ext/spl/tests/pqueue_001.phpt:1.1   Mon Feb 25 23:36:36 2008
+++ php-src/ext/spl/tests/pqueue_001.phpt       Thu May 15 17:05:20 2008
@@ -5,6 +5,7 @@
 --FILE--
 <?php
 $pq = new SplPriorityQueue();
+echo $pq->getExtractFlags()."\n";
 
 // errors
 try {
@@ -25,6 +26,7 @@
 
 $pq1 = new SplPriorityQueue();
 $pq1->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
+echo $pq1->getExtractFlags()."\n";
 
 $pq1->insert("a", 1);
 $pq1->insert("b", 2);
@@ -38,6 +40,7 @@
 
 $pq2 = new SplPriorityQueue();
 $pq2->setExtractFlags(SplPriorityQueue::EXTR_DATA);
+echo $pq2->getExtractFlags()."\n";
 
 $pq2->insert("a", 1);
 $pq2->insert("b", 2);
@@ -51,6 +54,7 @@
 
 $pq3 = new SplPriorityQueue();
 $pq3->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
+echo $pq3->getExtractFlags()."\n";
 
 $pq3->insert("a", 1);
 $pq3->insert("b", 2);
@@ -64,11 +68,13 @@
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
+1
 Exception: Can't extract from an empty heap
 3=>b
 2=>a
 1=>c
 EXTR_BOTH
+3
 3=>Array
 (
     [data] => b
@@ -88,10 +94,12 @@
 )
 
 EXTR_DATA
+1
 3=>b
 2=>a
 1=>c
 EXTR_PRIORITY
+2
 3=>2
 2=>1
 1=>0



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

Reply via email to