Skip to content
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

STL hash to avoid int traps #9

Open
wants to merge 1 commit into
base: hydro-devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions footstep_planner/include/footstep_planner/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#include <angles/angles.h>
#include <tf/tf.h>

#include <math.h>
#include <functional>
#include <cmath>


namespace footstep_planner
Expand Down Expand Up @@ -147,15 +148,9 @@ inline double cont_val(int length, double cell_size)
/// @return The hash value of the key.
inline unsigned int int_hash(int key)
{
key += (key << 12);
key ^= (key >> 22);
key += (key << 4);
key ^= (key >> 9);
key += (key << 10);
key ^= (key >> 2);
key += (key << 7);
key ^= (key >> 12);
return key;
static std::hash<int> hash_fn;

return hash_fn( key );
}


Expand Down