Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_set.hpp
1#ifndef TEUCHOS_SET_HPP
2#define TEUCHOS_SET_HPP
3
4#include <set>
5#include <iosfwd>
6#include <Teuchos_Assert.hpp>
7
8namespace Teuchos {
9
10template <typename T>
11void unite_with(std::set<T>& a, std::set<T> const& b) {
12 for (typename std::set<T>::const_iterator it = b.begin(); it != b.end(); ++it) {
13 const T& x = *it;
14 a.insert(x);
15 }
16}
17
18template <typename T>
19void unite(std::set<T>& result, std::set<T> const& a, std::set<T> const& b) {
20 result = a;
21 unite_with(result, b);
22}
23
24template <typename T>
25void subtract_from(std::set<T>& a, std::set<T> const& b) {
26 for (typename std::set<T>::const_iterator it = b.begin(); it != b.end(); ++it) {
27 const T& x = *it;
28 typename std::set<T>::iterator it2 = a.find(x);
29 if (it2 == a.end()) continue;
30 a.erase(it2);
31 }
32}
33
34template <typename T>
35bool intersects(std::set<T> const& a, std::set<T> const& b) {
36 for (typename std::set<T>::const_iterator it = b.begin(); it != b.end(); ++it) {
37 const T& x = *it;
38 typename std::set<T>::const_iterator it2 = a.find(x);
39 if (it2 != a.end()) return true;
40 }
41 return false;
42}
43
44}
45
46#endif
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...