Closed zijinoier closed 4 years ago
Thanks for pointing that out, this is certainly a bug (see also notes 1 and 3 in https://en.cppreference.com/w/cpp/algorithm/set_intersection). I think there are two potential solutions: 1) switch to a regular std::set, 2) use a foreach loop and https://en.cppreference.com/w/cpp/container/unordered_set/count for the check. Option 2) would eliminate the need to create the intersections explicitly, so might be actually better for this function.
Yeah. I agree with that option (2) is certainly a better solution. I am glad to fix this problem and submit a pull request😊
I just pushed a fix - sorry a PR would have been great too, but I saw this message too late. As noted in the commit https://github.com/whoenig/libMultiRobotPlanning/commit/2a757de816e2574d0ba108a2ad905732fe66d91f, this bug luckily did not affect correctness, because the overlap function is only used in DEBUG builds as assertion.
That would be great - PRs are always welcome!
When I reading
overlap
function inConstraints
struct fromcbs.cpp
, I encounter this:As I know,
std::set_intersection
can only work on ordered set likestd::set
. The function may not work properly onstd::unordered_set
. https://stackoverflow.com/questions/48158811/c-library-method-for-intersection-of-two-unordered-setHope for your reply:)