2006-11-08 Ada Chan <adachan@apple.com>
authoradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2006 21:20:26 +0000 (21:20 +0000)
committeradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2006 21:20:26 +0000 (21:20 +0000)
        Reviewed by darin.

        Added a method to delete all the keys in a HashMap.

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

JavaScriptCore/ChangeLog
JavaScriptCore/wtf/HashMap.h

index a10d431..360693a 100644 (file)
@@ -1,3 +1,13 @@
+2006-11-08  Ada Chan  <adachan@apple.com>
+
+        Reviewed by darin.
+        
+        Added a method to delete all the keys in a HashMap.
+
+        * wtf/HashMap.h:
+        (WTF::deleteAllPairFirsts):
+        (WTF::deleteAllKeys):
+
 2006-11-07  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Geoff.
index a06b083..eef38c2 100644 (file)
@@ -320,6 +320,21 @@ namespace WTF {
         deleteAllPairSeconds<typename HashMap<T, U, V, W, X>::MappedType>(collection);
     }
 
+    template<typename KeyType, typename HashTableType>
+    void deleteAllPairFirsts(HashTableType& collection)
+    {
+        typedef typename HashTableType::const_iterator iterator;
+        iterator end = collection.end();
+        for (iterator it = collection.begin(); it != end; ++it)
+            delete *(KeyType*)&it->first;
+    }
+
+    template<typename T, typename U, typename V, typename W, typename X>
+    inline void deleteAllKeys(const HashMap<T, U, V, W, X>& collection)
+    {
+        deleteAllPairFirsts<typename HashMap<T, U, V, W, X>::KeyType>(collection);
+    }
+
 } // namespace WTF
 
 using WTF::HashMap;