+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.
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