[svn:parrot] r39620 - branches/tt761_keys_revamp/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Jun 17 12:43:12 UTC 2009


Author: bacek
Date: Wed Jun 17 12:43:11 2009
New Revision: 39620
URL: https://trac.parrot.org/parrot/changeset/39620

Log:
[pmc] Implement HashIterator.elements. Fix comments.

Modified:
   branches/tt761_keys_revamp/src/pmc/hashiterator.pmc

Modified: branches/tt761_keys_revamp/src/pmc/hashiterator.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/hashiterator.pmc	Wed Jun 17 11:46:49 2009	(r39619)
+++ branches/tt761_keys_revamp/src/pmc/hashiterator.pmc	Wed Jun 17 12:43:11 2009	(r39620)
@@ -71,6 +71,7 @@
         bucket = attrs->parrot_hash->bi[attrs->pos++];
     }
     attrs->bucket = bucket;
+    attrs->elements--;
     return bucket;
 }
 
@@ -80,6 +81,7 @@
     ATTR HashBucket *bucket;        /* Current bucket */
     ATTR INTVAL      total_buckets; /* */
     ATTR INTVAL      pos;           /* */
+    ATTR INTVAL      elements;      /* How many elements left to iterate over */
 
 /*
 
@@ -101,6 +103,9 @@
         attrs->total_buckets    = attrs->parrot_hash->mask + 1;
         attrs->bucket           = 0;
         attrs->pos              = 0;
+        /* Will be decreased on initial advance_to_next */
+        /* XXX Do we really need to support this use-case ? */
+        attrs->elements         = attrs->parrot_hash->entries + 1;
         PMC_data(SELF)          = attrs;
 
         PObj_custom_mark_destroy_SETALL(SELF);
@@ -181,14 +186,14 @@
 
 =item C<INTVAL elements()>
 
-Returns the number of remaining elements in the array.
+Returns the number of remaining elements in the Hash.
 
 =cut
 
 */
 
     VTABLE INTVAL elements() {
-        return 0;
+        return PARROT_HASHITERATOR(SELF)->elements;
     }
 
     VTABLE INTVAL get_integer() {


More information about the parrot-commits mailing list