12 #ifndef EMP_SET_UTILS_H 13 #define EMP_SET_UTILS_H 16 #include <unordered_set> 18 #include "../base/vector.h" 24 void insert(std::set<T> & s1,
const std::set<T> & s2) {
25 s1.insert(s2.begin(), s2.end());
29 template <
typename T,
typename H>
30 bool Has(
const std::set<T,H> & s,
const T & val) {
return s.count(val); }
33 template <
typename T,
typename H>
34 bool Has(
const std::multiset<T,H> & s,
const T & val) {
return s.count(val); }
37 template <
typename T,
typename H>
38 bool Has(
const std::unordered_set<T,H> & s,
const T & val) {
return s.count(val); }
41 template <
typename T,
typename H>
42 bool Has(
const std::unordered_multiset<T,H> & s,
const T & val) {
return s.count(val); }
50 std::set<T>
difference(std::set<T> & s1, std::set<T> & s2) {
53 std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),
54 std::inserter(result, result.end()));
67 std::inserter(result, result.end()));
77 std::set_difference(s1.begin(), s1.end(), s2.
begin(), s2.
end(),
78 std::inserter(result, result.end()));
88 std::set_difference(s1.
begin(), s1.
end(), s2.begin(), s2.end(),
89 std::inserter(result, result.end()));
97 std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
98 std::inserter(result, result.end()));
103 template <
typename T>
110 std::inserter(result, result.end()));
115 template <
typename T>
120 std::set_intersection(s1.begin(), s1.end(), s2.
begin(), s2.
end(),
121 std::inserter(result, result.end()));
126 template <
typename T>
131 std::set_intersection(s1.
begin(), s1.
end(), s2.begin(), s2.end(),
132 std::inserter(result, result.end()));
137 template <
typename T>
141 std::inserter(result, result.end()));
146 template <
typename T>
153 std::inserter(result, result.end()));
158 template <
typename T>
164 std::inserter(result, result.end()));
169 template <
typename T>
175 std::inserter(result, result.end()));
180 template <
typename T>
183 std::set_symmetric_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),
184 std::inserter(result, result.end()));
189 template <
typename T>
196 std::inserter(result, result.end()));
201 template <
typename T>
206 std::set_symmetric_difference(s1.begin(), s1.end(), s2.
begin(), s2.
end(),
207 std::inserter(result, result.end()));
212 template <
typename T>
217 std::set_symmetric_difference(s1.
begin(), s1.
end(), s2.begin(), s2.end(),
218 std::inserter(result, result.end()));
std::set< T > intersection(std::set< T > s1, std::set< T > s2)
Compute the set intersection of.
Definition: set_utils.h:95
iterator end() noexcept
Definition: vector.h:155
std::set< T > set_union(emp::vector< T > s1, std::set< T > s2)
Compute the set union of.
Definition: set_utils.h:170
std::set< T > set_union(std::set< T > s1, std::set< T > s2)
Compute the set union of.
Definition: set_utils.h:138
bool Has(const MAP_T &in_map, const KEY_T &key)
Take any map type, and run find to determine if a key is present.
Definition: map_utils.h:21
void insert(std::set< T > &s1, const std::set< T > &s2)
Insert the full contents of s2 into s1.
Definition: set_utils.h:24
iterator begin() noexcept
Definition: vector.h:153
If we are in emscripten, make sure to include the header.
Definition: array.h:37
std::set< T > difference(std::set< T > &s1, std::set< T > &s2)
Compute the set difference of.
Definition: set_utils.h:50
std::set< T > symmetric_difference(std::set< T > s1, std::set< T > s2)
Compute the set symmetric_difference of.
Definition: set_utils.h:181
typename internal::ip_sort< T >::result sort
Definition: IntPack.h:193