From 0dcc28794153156eaf8aa6c09e8f4a2e4c3ecbab Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 23 Jan 2025 17:23:12 +0100 Subject: [PATCH] add CGAL::unordered_flat_set --- .../include/CGAL/unordered_flat_map.h | 27 +++++++++++++++++++ .../include/CGAL/unordered_flat_set.h | 17 ++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 STL_Extension/include/CGAL/unordered_flat_set.h diff --git a/STL_Extension/include/CGAL/unordered_flat_map.h b/STL_Extension/include/CGAL/unordered_flat_map.h index 8eb3203f87e..73ff2135033 100644 --- a/STL_Extension/include/CGAL/unordered_flat_map.h +++ b/STL_Extension/include/CGAL/unordered_flat_map.h @@ -18,12 +18,19 @@ # define CGAL_USE_BOOST_UNORDERED 1 #endif +#if CGAL_USE_BARE_STD_SET +# define CGAL_USE_BARE_STD_MAP CGAL_USE_BARE_STD_SET +#endif + #if CGAL_USE_BARE_STD_MAP // to benchmark with the ordered std::map # include +# include #elif CGAL_USE_BOOST_UNORDERED # include +# include #else // Boost before 1.81.0, use the C++11 std::unordered_map # include +# include #endif #include // for std::hash, std::equal_to @@ -52,6 +59,26 @@ template < #endif +template < + typename Key, + typename Hash = std::hash, + typename KeyEqual = std::equal_to, + typename Allocator = std::allocator + > +#if CGAL_USE_BARE_STD_MAP + + using unordered_flat_set = std::set, Allocator>; + +#elif CGAL_USE_BOOST_UNORDERED + + using unordered_flat_set = boost::unordered_flat_set; + +#else // use the C++11 std::unordered_set + + using unordered_flat_set = std::unordered_set; + +#endif + } // end namespace CGAL #endif // CGAL_UNORDERED_FLAT_MAP_H diff --git a/STL_Extension/include/CGAL/unordered_flat_set.h b/STL_Extension/include/CGAL/unordered_flat_set.h new file mode 100644 index 00000000000..bf71b173013 --- /dev/null +++ b/STL_Extension/include/CGAL/unordered_flat_set.h @@ -0,0 +1,17 @@ +// Copyright (c) 2025 GeometryFactory Sarl (France). +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Laurent Rineau + +#ifndef CGAL_UNORDERED_FLAT_SET_H +#define CGAL_UNORDERED_FLAT_SET_H + +// lazy implementation: define the two template aliases in the same header file +#include + +#endif // CGAL_UNORDERED_FLAT_SET_H