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 a10d431cb4f242f95b0da72c1c348f9e7056d39e..360693a774d98d136df2dd000d252dd00a1a7925 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 a06b083edde57bdb1546ba70ad3890dd1d0c1db1..eef38c20d2948f5a27485db89fbbe91da7ece5db 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;