| 294 | */ |
| 295 | template<typename T> |
| 296 | void removeFromSet(std::set<T> &from, const std::set<T> &toRemove) { |
| 297 | // The solution using std::set_difference<> is slightly faster |
| 298 | // than this manual loop: |
| 299 | // |
| 300 | // for (auto &item : toRemove) { |
| 301 | // from.erase(item); |
| 302 | // } |
| 303 | // |
| 304 | // Timings (containers with 10000000 elements): |
| 305 | // |
| 306 | // T | std::set_difference | for loop | |
| 307 | // ------------|---------------------|----------| |
| 308 | // int | 3.08s | 4.43s | |
| 309 | // std::string | 3.74s | 6.87s | |
| 310 | // |
| 311 | from = setDifference(from, toRemove); |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * @brief Returns @c true if @a s1 is disjoint with @a s2. |