add CGAL::unordered_flat_set

This commit is contained in:
Laurent Rineau 2025-01-23 17:23:12 +01:00
parent 3d61960ea3
commit 0dcc287941
2 changed files with 44 additions and 0 deletions

View File

@ -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 <map>
# include <set>
#elif CGAL_USE_BOOST_UNORDERED
# include <boost/unordered/unordered_flat_map.hpp>
# include <boost/unordered/unordered_flat_set.hpp>
#else // Boost before 1.81.0, use the C++11 std::unordered_map
# include <unordered_map>
# include <unordered_set>
#endif
#include <functional> // for std::hash, std::equal_to
@ -52,6 +59,26 @@ template <
#endif
template <
typename Key,
typename Hash = std::hash<Key>,
typename KeyEqual = std::equal_to<Key>,
typename Allocator = std::allocator<Key>
>
#if CGAL_USE_BARE_STD_MAP
using unordered_flat_set = std::set<Key, std::less<Key>, Allocator>;
#elif CGAL_USE_BOOST_UNORDERED
using unordered_flat_set = boost::unordered_flat_set<Key, Hash, KeyEqual, Allocator>;
#else // use the C++11 std::unordered_set
using unordered_flat_set = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
#endif
} // end namespace CGAL
#endif // CGAL_UNORDERED_FLAT_MAP_H

View File

@ -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 <CGAL/unordered_flat_map.h>
#endif // CGAL_UNORDERED_FLAT_SET_H