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