Skip to content

Commit

Permalink
optimize the vec dis joint
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Oct 18, 2024
1 parent 29fff3f commit 3816dae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pennylane_lightning/core/src/utils/Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,11 @@ std::vector<T1> cast_vector(const std::vector<T0> &vec) {
template <typename T = std::size_t>
bool areVecsDisjoint(const std::vector<T> &v1, const std::vector<T> &v2) {
std::set<T> s0(v1.begin(), v1.end());
s0.insert(v2.begin(), v2.end());
return s0.size() == v1.size() + v2.size();
for (const auto &element : v2) {
if (s0.find(element) != s0.end()) {
return false;
}
}
return true;
}
} // namespace Pennylane::Util

0 comments on commit 3816dae

Please sign in to comment.