fix an issue that node sockets can be duplicated

This commit is contained in:
2022-09-26 12:45:05 +09:00
parent 5ef347fa2e
commit b949383932
3 changed files with 19 additions and 1 deletions

View File

@@ -7,14 +7,17 @@
namespace nf7::util {
template <typename T>
inline void Uniq(std::vector<T>& v) noexcept {
inline size_t Uniq(std::vector<T>& v) noexcept {
size_t n = 0;
for (auto itr = v.begin(); itr < v.end();) {
if (v.end() != std::find(itr+1, v.end(), *itr)) {
itr = v.erase(itr);
++n;
} else {
++itr;
}
}
return n;
}
} // namespace nf7::util