added pull to open-addressing containers (#309)

* added pull to open-addressing containers

* added pull_tests.cpp

* guarded pull against exceptions in mid init_type construction
This commit is contained in:
joaquintides
2025-04-14 21:47:30 +02:00
committed by GitHub
parent 2907fe8c98
commit 3dde65b2ef
13 changed files with 173 additions and 6 deletions
+9 -1
View File
@@ -1,6 +1,6 @@
/* Fast open-addressing hash table.
*
* Copyright 2022-2024 Joaquin M Lopez Munoz.
* Copyright 2022-2025 Joaquin M Lopez Munoz.
* Copyright 2023 Christian Mazakas.
* Copyright 2024 Braden Ganetsky.
* Distributed under the Boost Software License, Version 1.0.
@@ -495,6 +495,14 @@ public:
else return 0;
}
BOOST_FORCEINLINE init_type pull(const_iterator pos)
{
BOOST_ASSERT(pos!=end());
erase_on_exit e{*this,pos};
(void)e;
return type_policy::move(type_policy::value_from(*pos.p()));
}
void swap(table& x)
noexcept(noexcept(std::declval<super&>().swap(std::declval<super&>())))
{
@@ -1,5 +1,5 @@
// Copyright (C) 2022-2023 Christian Mazakas
// Copyright (C) 2024 Joaquin M Lopez Munoz
// Copyright (C) 2024-2025 Joaquin M Lopez Munoz
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -438,6 +438,11 @@ namespace boost {
return table_.erase(key);
}
BOOST_FORCEINLINE init_type pull(const_iterator pos)
{
return table_.pull(pos);
}
void swap(unordered_flat_map& rhs) noexcept(
noexcept(std::declval<table_type&>().swap(std::declval<table_type&>())))
{
@@ -1,5 +1,5 @@
// Copyright (C) 2022-2023 Christian Mazakas
// Copyright (C) 2024 Joaquin M Lopez Munoz
// Copyright (C) 2024-2025 Joaquin M Lopez Munoz
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -332,6 +332,11 @@ namespace boost {
return table_.erase(key);
}
BOOST_FORCEINLINE init_type pull(const_iterator pos)
{
return table_.pull(pos);
}
void swap(unordered_flat_set& rhs) noexcept(
noexcept(std::declval<table_type&>().swap(std::declval<table_type&>())))
{
@@ -1,5 +1,5 @@
// Copyright (C) 2022-2023 Christian Mazakas
// Copyright (C) 2024 Joaquin M Lopez Munoz
// Copyright (C) 2024-2025 Joaquin M Lopez Munoz
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -483,6 +483,11 @@ namespace boost {
return table_.erase(key);
}
BOOST_FORCEINLINE init_type pull(const_iterator pos)
{
return table_.pull(pos);
}
void swap(unordered_node_map& rhs) noexcept(
noexcept(std::declval<table_type&>().swap(std::declval<table_type&>())))
{
@@ -1,5 +1,5 @@
// Copyright (C) 2022-2023 Christian Mazakas
// Copyright (C) 2024 Joaquin M Lopez Munoz
// Copyright (C) 2024-2025 Joaquin M Lopez Munoz
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -379,6 +379,11 @@ namespace boost {
return table_.erase(key);
}
BOOST_FORCEINLINE init_type pull(const_iterator pos)
{
return table_.pull(pos);
}
void swap(unordered_node_set& rhs) noexcept(
noexcept(std::declval<table_type&>().swap(std::declval<table_type&>())))
{