vertex.hpp 955 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef VERTEX_HPP
  2. #define VERTEX_HPP
  3. #include <cstdint>
  4. #include <unordered_map>
  5. using namespace std;
  6. using int32=int32_t;
  7. using uint32=uint32_t;
  8. using uint64=uint64_t;
  9. using int64=int64_t;
  10. class Vertex{
  11. public:
  12. int32 x,y;
  13. Vertex();
  14. Vertex(int x,int y);
  15. Vertex(const Vertex& v);
  16. bool operator==(const Vertex& v);
  17. };
  18. inline
  19. Vertex::Vertex(){
  20. }
  21. inline
  22. Vertex::Vertex(int32 _x,int32 _y):x(_x),y(_y){
  23. }
  24. inline Vertex::Vertex(const Vertex& v){
  25. x=v.x;
  26. y=v.y;
  27. }
  28. template<>
  29. struct std::hash<Vertex>{
  30. size_t operator()(const Vertex& v) const;
  31. };
  32. template<>
  33. struct std::equal_to<Vertex>{
  34. constexpr bool operator()(const Vertex& u,const Vertex& v) const;
  35. };
  36. inline size_t
  37. std::hash<Vertex>::operator()(const Vertex& v) const{
  38. uint64 x=(uint32)v.x;
  39. uint64 y=(uint32)v.y;
  40. return (x<<32)+y;
  41. }
  42. inline constexpr bool
  43. std::equal_to<Vertex>::operator()(const Vertex& u,const Vertex& v) const{
  44. return u.x==v.x and u.y==v.y;
  45. }
  46. #endif