-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue1088 #156
issue1088 #156
Conversation
src/search/lp/lp_solver.cc
Outdated
#ifndef NDEBUG | ||
template<class T> | ||
static bool all_values_are_unique(const vector<T> &v) { | ||
set<T> s(v.begin(), v.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set<T> s(v.begin(), v.end()); | |
unordered_set<T> s(v.begin(), v.end()); |
since we don't require a sorted container.
src/search/lp/lp_solver.cc
Outdated
@@ -37,6 +37,14 @@ using namespace std; | |||
using utils::ExitCode; | |||
|
|||
namespace lp { | |||
#ifndef NDEBUG | |||
template<class T> | |||
static bool all_values_are_unique(const vector<T> &v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this function next to sorted_unique?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar enough with our conventions here. Moving it to collections.h
would require an import in lp_solver.cc
even though the function is only used in debug mode. I tried to avoid any changes in the release build by defining the function close to where it is used and building it only in debug mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You currently also have an additional import here (for unordered_set
). I think treat both the algorithm and the utils namespace as something that may be included everywhere. But same as Jendrik, I'm also fine either way. It certainly has an advantage to make the module as independent from other modules as possible and we could always make the function more public later on if we need it somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I overlooked that because I first used set
which didn't need the extra import. ;)
The disadvantage of defining it locally is that somebody else might define something similar locally unaware of this function here. So I'll just move it to utils
until somebody has a stronger opinion in a different direction.
src/search/lp/lp_solver.cc
Outdated
|
||
using namespace std; | ||
using utils::ExitCode; | ||
|
||
namespace lp { | ||
#ifndef NDEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you get an "unused function" error without this? If not, I'd reduce the number of preprocessor directives and just always define the function (it shouldn't have a performance impact if it is not used). I have no strong opinion, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I thought that's something we do if something's used only in debug mode. I'll remove it.
Assert that LP constraints contain every variable at most once.