Advertisement
Glenpl

Untitled

Aug 23rd, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. struct Key // koordynaty hexa
  2. {
  3.     int x, y, z;
  4.     Key(int x, int y, int z) : x(x), y(y), z(z) {}
  5.  
  6.     bool operator==(const Key &other) const
  7.     {
  8.         return (x == other.x && y == other.y && z == other.z);
  9.     }
  10. };
  11.  
  12. struct KeyHasher
  13. {
  14.     const int c = 1000; // wartosc wieksza niz bok mapy i c^3 < max unsigned long size
  15.     std::size_t operator()(const Key& k) const
  16.     {
  17.         return static_cast<std::size_t>(x + (y*c) + (z*c*c));
  18.     }
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement