Add specializations of hash

This commit is contained in:
Andreas Fabri 2015-04-17 10:44:43 +02:00
parent 7f0bdd272d
commit 0eaa9235d0
2 changed files with 20 additions and 5 deletions

View File

@ -67,9 +67,10 @@ public:
return *this;
}
Face_handle face_handle() const
std::size_t hash() const
{
return this->first;
std::hash<Face_handle> fct;
return fct(this->first);
}
bool operator==(const Edge& other) const
@ -273,6 +274,12 @@ public:
: first(fd), second(i)
{}
std::size_t hash() const
{
std::hash<face_descriptor> fct;
return fct(first);
}
bool operator==(const T2_halfedge_descriptor& other) const
{
return (first == other.first) && (second == other.second);
@ -830,8 +837,16 @@ namespace std {
std::size_t operator()(const CGAL::detail::Edge<T,EdgeBase>& e)
{
std::cerr << "Triangulation_2::Edge HashFct" << std::endl;
std::hash<typename CGAL::detail::Edge<T,EdgeBase>::Face_handle> fct;
return fct(e.face_handle());
return e.hash();
}
};
template < class Tr>
struct hash<CGAL::detail::T2_halfedge_descriptor<Tr> > {
std::size_t operator()(const CGAL::detail::T2_halfedge_descriptor<Tr>& e)
{
std::cerr << "Triangulation_2::halfedge_descriptor HashFct" << std::endl;
return e.hash();
}
};
} // namespace std

View File

@ -49,7 +49,7 @@ int main()
std::cout << "\ngraph_traits<Triangulation_2>::_descriptor"<< std::endl;
Unordered<boost::graph_traits<Triangulation_2>::vertex_descriptor> U3;
// Unordered<boost::graph_traits<Triangulation_2>::halfedge_descriptor> U4;
Unordered<boost::graph_traits<Triangulation_2>::halfedge_descriptor> U4;
Unordered<boost::graph_traits<Triangulation_2>::edge_descriptor> U5;
Unordered<boost::graph_traits<Triangulation_2>::face_descriptor> U6;
}