From 2b43a79e0aa5dae6000672f04deeda0c1e3a8cbd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 5 Oct 2015 10:15:24 +0200 Subject: [PATCH] Add hashing to the concurent compact container --- Hash_map/test/Hash_map/Hash.cpp | 27 +++++++++++++++++ .../CGAL/Concurrent_compact_container.h | 30 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Hash_map/test/Hash_map/Hash.cpp b/Hash_map/test/Hash_map/Hash.cpp index caaed81dbd8..9a4e5514016 100644 --- a/Hash_map/test/Hash_map/Hash.cpp +++ b/Hash_map/test/Hash_map/Hash.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,14 @@ typedef CGAL::Arrangement_2 Arrangement_2; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::Surface_mesh Surface_mesh; typedef CGAL::Triangulation_2 Triangulation_2; +#ifdef CGAL_LINKED_WITH_TBB +typedef CGAL::Triangulation_data_structure_3< + CGAL::Triangulation_vertex_base_3, + CGAL::Triangulation_cell_base_3, + CGAL::Parallel_tag> Tds; +typedef CGAL::Delaunay_triangulation_3 Triangulation_3; +#endif + typedef CGAL::Linear_cell_complex<3, 3> Linear_cell_complex_3; @@ -59,6 +68,20 @@ void fct2() } } +template +void +fct3(const P& ) +{ + typedef typename P::Vertex_handle vertex_descriptor; + + std::map M; + vertex_descriptor vd; + M.find(vd); + + boost::unordered_map U; + U[vd] = 12; +} + int main() { Arrangement_2 A; @@ -75,6 +98,10 @@ int main() fct2(); +#ifdef CGAL_LINKED_WITH_TBB + Triangulation_3 T3; +fct3(T3); +#endif return 0; } diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 3d825bfd47f..6f85eb09c00 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -1022,9 +1022,39 @@ namespace CCC_internal { return rhs.operator->() != NULL; } + template + std::size_t hash_value(const CCC_iterator& i) + { + return reinterpret_cast(&*i) / sizeof(typename CCC::value_type); + } } // namespace CCC_internal } //namespace CGAL +namespace std { + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4099) // For VC10 it is class hash +#endif + +#ifndef CGAL_CFG_NO_STD_HASH + + template < class CCC, bool Const > + struct hash > + : public std::unary_function, std::size_t> { + + std::size_t operator()(const CGAL::CCC_internal::CCC_iterator& i) const + { + return reinterpret_cast(&*i) / sizeof(typename CCC::value_type); + } + }; +#endif // CGAL_CFG_NO_STD_HASH + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +} // namespace std #endif // CGAL_CONCURRENT_COMPACT_CONTAINER_H