Chromium Code Reviews| Index: base/stl_util.h |
| diff --git a/base/stl_util.h b/base/stl_util.h |
| index b3ddfa3b4fe8f85bb9568768d1a2af9fd7c75d19..4e0826c5ffb3acd307e19d67239891fcc6ff8d33 100644 |
| --- a/base/stl_util.h |
| +++ b/base/stl_util.h |
| @@ -7,6 +7,8 @@ |
| #ifndef BASE_STL_UTIL_H_ |
| #define BASE_STL_UTIL_H_ |
| +#include <algorithm> |
| +#include <set> |
| #include <string> |
| #include <vector> |
| @@ -191,4 +193,15 @@ bool ContainsKey(const Collection& collection, const Key& key) { |
| return collection.find(key) != collection.end(); |
| } |
| +// Returns a new std::set containing the difference of two sets. |
| +// A convenient wrapper around std::set_difference. |
| +template <typename T> |
| +std::set<T> STLSetDifference(const std::set<T>& a, const std::set<T>& b) { |
|
Jeffrey Yasskin
2012/11/30 23:00:16
I agree with the decision to only provide one over
Jeffrey Yasskin
2012/11/30 23:06:21
I'm just being dumb. insert_iterator uses 'iter =
|
| + std::set<T> difference; |
| + std::set_difference(a.begin(), a.end(), |
| + b.begin(), b.end(), |
| + std::inserter(difference, difference.end())); |
| + return difference; |
| +} |
| + |
| #endif // BASE_STL_UTIL_H_ |