Files
jak-project/common/util/set_util.h
T
Tyler Wilding 997c1ab60a decomp: add explicit failures for common config mistakes related to allowed_objs (#2062)
A common thing that can be forgotten about / confusing to new people is
that:
1. if you add an object to the `allowed_objs` list but it's also in the
`banned_objs` list -- the ban still takes precedence with no failure
2. if you add an object to the `allowed_objs` list but have not allowed
the DGO in `inputs.jsonc` it will also silently log a failure and
continue.

This PR turns both situations into an explicit error with advice/a
reminder on what to do to fix it.
2022-12-30 14:01:55 -05:00

23 lines
485 B
C++

#pragma once
#include <unordered_set>
namespace set_util {
template <typename T>
std::unordered_set<T> intersection(std::unordered_set<T>& set1, std::unordered_set<T>& set2) {
if (set2.size() < set1.size()) {
auto temp = set1;
set1 = set2;
set2 = temp;
}
std::unordered_set<T> m(set1.begin(), set1.end());
std::unordered_set<T> res;
for (auto a : set2)
if (m.count(a)) {
res.insert(a);
m.erase(a);
}
return res;
}
} // namespace set_util