Reviewed by Geoff
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2007 06:04:21 +0000 (06:04 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2007 06:04:21 +0000 (06:04 +0000)
        Add copyKeysToVector utility, mirroring copyValuesToVector
        Also change the copyValuesToVector implementation to be a little more attractive

        * wtf/HashMap.h:
        (WTF::copyKeysToVector):
        (WTF::copyValuesToVector):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28132 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/wtf/HashMap.h

index 203f95fa4ab1b585945b8282e48d9f7c5e45c02b..1c6bf019b5d3c3381ae38b55c608871b78a9def5 100644 (file)
@@ -1,3 +1,14 @@
+2007-11-28  Brady Eidson <beidson@apple.com>
+
+        Reviewed by Geoff
+
+        Add copyKeysToVector utility, mirroring copyValuesToVector
+        Also change the copyValuesToVector implementation to be a little more attractive
+
+        * wtf/HashMap.h:
+        (WTF::copyKeysToVector):
+        (WTF::copyValuesToVector):
+
 2007-11-27  Alp Toker  <alp@atoker.com>
 
         Reviewed by Mark Rowe.
index 7d83694d92317fa91b1bbc0b75ba3a117b8c55ec..a598b3d138893d95114a88d25b92ae5374f7400a 100644 (file)
@@ -393,17 +393,30 @@ namespace WTF {
         deleteAllPairFirsts<typename HashMap<T, U, V, W, X>::KeyType>(collection);
     }
     
+    template<typename T, typename U, typename V, typename W, typename X>
+    inline void copyKeysToVector(const HashMap<T, U, V, W, X>& collection, Vector<T>& vector)
+    {
+        typedef typename HashMap<T, U, V, W, X>::const_iterator::Keys iterator;
+        
+        vector.resize(collection.size());
+        
+        iterator it = collection.begin().keys();
+        iterator end = collection.end().keys();
+        for (unsigned i = 0; it != end; ++it, ++i)
+            vector[i] = *it;
+    }  
+
     template<typename T, typename U, typename V, typename W, typename X>
     inline void copyValuesToVector(const HashMap<T, U, V, W, X>& collection, Vector<U>& vector)
     {
-        typedef typename HashMap<T, U, V, W, X>::const_iterator iterator;
+        typedef typename HashMap<T, U, V, W, X>::const_iterator::Values iterator;
         
         vector.resize(collection.size());
         
-        iterator it = collection.begin();
-        iterator end = collection.end();
+        iterator it = collection.begin().values();
+        iterator end = collection.end().values();
         for (unsigned i = 0; it != end; ++it, ++i)
-            vector[i] = (*it).second;
+            vector[i] = *it;
     }   
 
 } // namespace WTF