aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/abseil-cpp-tstring/y_absl/container
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:43 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:43 +0300
commit397cbe258b9e064f49c4ca575279f02f39fef76e (patch)
treea0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/restricted/abseil-cpp-tstring/y_absl/container
parent43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff)
downloadydb-397cbe258b9e064f49c4ca575279f02f39fef76e.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/abseil-cpp-tstring/y_absl/container')
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/.yandex_meta/licenses.list.txt48
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h32
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h6
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h22
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h88
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h14
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h6
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h72
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/absl_hashtablez_sampler/ya.make68
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h1208
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h342
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h12
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h70
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h98
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h104
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h12
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h48
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc14
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h76
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc4
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/have_sse.h20
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h160
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h22
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc14
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h346
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make12
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h2
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h4
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h14
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h34
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make28
31 files changed, 1500 insertions, 1500 deletions
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/.yandex_meta/licenses.list.txt b/contrib/restricted/abseil-cpp-tstring/y_absl/container/.yandex_meta/licenses.list.txt
index f39e683596..27eb40bafa 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/.yandex_meta/licenses.list.txt
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/.yandex_meta/licenses.list.txt
@@ -1,24 +1,24 @@
-====================Apache-2.0====================
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-====================COPYRIGHT====================
-// Copyright 2017 The Abseil Authors.
-
-
-====================COPYRIGHT====================
-// Copyright 2018 The Abseil Authors.
-
-
-====================COPYRIGHT====================
-// Copyright 2019 The Abseil Authors.
+====================Apache-2.0====================
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+====================COPYRIGHT====================
+// Copyright 2017 The Abseil Authors.
+
+
+====================COPYRIGHT====================
+// Copyright 2018 The Abseil Authors.
+
+
+====================COPYRIGHT====================
+// Copyright 2019 The Abseil Authors.
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h
index 3f46c541b8..298b259885 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h
@@ -185,7 +185,7 @@ class btree_map
// template <typename K> size_type erase(const K& key):
//
// Erases the element with the matching key, if it exists, returning the
- // number of elements erased (0 or 1).
+ // number of elements erased (0 or 1).
using Base::erase;
// btree_map::insert()
@@ -318,18 +318,18 @@ class btree_map
// Extracts the element at the indicated position and returns a node handle
// owning that extracted data.
//
- // template <typename K> node_type extract(const K& k):
+ // template <typename K> node_type extract(const K& k):
//
// Extracts the element with the key matching the passed key value and
// returns a node handle owning that extracted data. If the `btree_map`
// does not contain an element with a matching key, this function returns an
// empty node handle.
//
- // NOTE: when compiled in an earlier version of C++ than C++17,
- // `node_type::key()` returns a const reference to the key instead of a
- // mutable reference. We cannot safely return a mutable reference without
- // std::launder (which is not available before C++17).
- //
+ // NOTE: when compiled in an earlier version of C++ than C++17,
+ // `node_type::key()` returns a const reference to the key instead of a
+ // mutable reference. We cannot safely return a mutable reference without
+ // std::launder (which is not available before C++17).
+ //
// NOTE: In this context, `node_type` refers to the C++17 concept of a
// move-only type that owns and provides access to the elements in associative
// containers (https://en.cppreference.com/w/cpp/container/node_handle).
@@ -384,8 +384,8 @@ class btree_map
// btree_map::equal_range()
//
- // Returns a half-open range [first, last), defined by a `std::pair` of two
- // iterators, containing all elements with the passed key in the `btree_map`.
+ // Returns a half-open range [first, last), defined by a `std::pair` of two
+ // iterators, containing all elements with the passed key in the `btree_map`.
using Base::equal_range;
// btree_map::find()
@@ -673,18 +673,18 @@ class btree_multimap
// Extracts the element at the indicated position and returns a node handle
// owning that extracted data.
//
- // template <typename K> node_type extract(const K& k):
+ // template <typename K> node_type extract(const K& k):
//
// Extracts the element with the key matching the passed key value and
// returns a node handle owning that extracted data. If the `btree_multimap`
// does not contain an element with a matching key, this function returns an
// empty node handle.
//
- // NOTE: when compiled in an earlier version of C++ than C++17,
- // `node_type::key()` returns a const reference to the key instead of a
- // mutable reference. We cannot safely return a mutable reference without
- // std::launder (which is not available before C++17).
- //
+ // NOTE: when compiled in an earlier version of C++ than C++17,
+ // `node_type::key()` returns a const reference to the key instead of a
+ // mutable reference. We cannot safely return a mutable reference without
+ // std::launder (which is not available before C++17).
+ //
// NOTE: In this context, `node_type` refers to the C++17 concept of a
// move-only type that owns and provides access to the elements in associative
// containers (https://en.cppreference.com/w/cpp/container/node_handle).
@@ -731,7 +731,7 @@ class btree_multimap
// btree_multimap::equal_range()
//
- // Returns a half-open range [first, last), defined by a `std::pair` of two
+ // Returns a half-open range [first, last), defined by a `std::pair` of two
// iterators, containing all elements with the passed key in the
// `btree_multimap`.
using Base::equal_range;
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h
index 905fb8e964..0c51f24be7 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h
@@ -183,7 +183,7 @@ class btree_set
// template <typename K> size_type erase(const K& key):
//
// Erases the element with the matching key, if it exists, returning the
- // number of elements erased (0 or 1).
+ // number of elements erased (0 or 1).
using Base::erase;
// btree_set::insert()
@@ -263,7 +263,7 @@ class btree_set
// Extracts the element at the indicated position and returns a node handle
// owning that extracted data.
//
- // template <typename K> node_type extract(const K& k):
+ // template <typename K> node_type extract(const K& k):
//
// Extracts the element with the key matching the passed key value and
// returns a node handle owning that extracted data. If the `btree_set`
@@ -589,7 +589,7 @@ class btree_multiset
// Extracts the element at the indicated position and returns a node handle
// owning that extracted data.
//
- // template <typename K> node_type extract(const K& k):
+ // template <typename K> node_type extract(const K& k):
//
// Extracts the element with the key matching the passed key value and
// returns a node handle owning that extracted data. If the `btree_multiset`
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h
index 97ed054ce8..76e2a4fd05 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h
@@ -25,7 +25,7 @@
#include "y_absl/container/btree_map.h"
#include "y_absl/container/btree_set.h"
#include "y_absl/container/flat_hash_set.h"
-#include "y_absl/strings/cord.h"
+#include "y_absl/strings/cord.h"
#include "y_absl/time/time.h"
namespace y_absl {
@@ -101,16 +101,16 @@ struct Generator<TString> {
}
};
-template <>
-struct Generator<Cord> {
- int maxval;
- explicit Generator(int m) : maxval(m) {}
- Cord operator()(int i) const {
- char buf[16];
- return Cord(GenerateDigits(buf, i, maxval));
- }
-};
-
+template <>
+struct Generator<Cord> {
+ int maxval;
+ explicit Generator(int m) : maxval(m) {}
+ Cord operator()(int i) const {
+ char buf[16];
+ return Cord(GenerateDigits(buf, i, maxval));
+ }
+};
+
template <typename T, typename U>
struct Generator<std::pair<T, U> > {
Generator<typename remove_pair_const<T>::type> tgen;
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h
index 33b6caf00d..afa8cc35b7 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h
@@ -41,7 +41,7 @@
#include <type_traits>
#include "y_absl/algorithm/algorithm.h"
-#include "y_absl/base/config.h"
+#include "y_absl/base/config.h"
#include "y_absl/base/dynamic_annotations.h"
#include "y_absl/base/internal/throw_delegate.h"
#include "y_absl/base/macros.h"
@@ -102,13 +102,13 @@ class FixedArray {
public:
using allocator_type = typename AllocatorTraits::allocator_type;
- using value_type = typename AllocatorTraits::value_type;
- using pointer = typename AllocatorTraits::pointer;
- using const_pointer = typename AllocatorTraits::const_pointer;
- using reference = value_type&;
- using const_reference = const value_type&;
- using size_type = typename AllocatorTraits::size_type;
- using difference_type = typename AllocatorTraits::difference_type;
+ using value_type = typename AllocatorTraits::value_type;
+ using pointer = typename AllocatorTraits::pointer;
+ using const_pointer = typename AllocatorTraits::const_pointer;
+ using reference = value_type&;
+ using const_reference = const value_type&;
+ using size_type = typename AllocatorTraits::size_type;
+ using difference_type = typename AllocatorTraits::difference_type;
using iterator = pointer;
using const_iterator = const_pointer;
using reverse_iterator = std::reverse_iterator<iterator>;
@@ -213,7 +213,7 @@ class FixedArray {
// Returns a reference the ith element of the fixed array.
// REQUIRES: 0 <= i < size()
reference operator[](size_type i) {
- ABSL_HARDENING_ASSERT(i < size());
+ ABSL_HARDENING_ASSERT(i < size());
return data()[i];
}
@@ -221,14 +221,14 @@ class FixedArray {
// ith element of the fixed array.
// REQUIRES: 0 <= i < size()
const_reference operator[](size_type i) const {
- ABSL_HARDENING_ASSERT(i < size());
+ ABSL_HARDENING_ASSERT(i < size());
return data()[i];
}
// FixedArray::at
//
- // Bounds-checked access. Returns a reference to the ith element of the fixed
- // array, or throws std::out_of_range
+ // Bounds-checked access. Returns a reference to the ith element of the fixed
+ // array, or throws std::out_of_range
reference at(size_type i) {
if (ABSL_PREDICT_FALSE(i >= size())) {
base_internal::ThrowStdOutOfRange("FixedArray::at failed bounds check");
@@ -248,32 +248,32 @@ class FixedArray {
// FixedArray::front()
//
// Returns a reference to the first element of the fixed array.
- reference front() {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[0];
- }
+ reference front() {
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[0];
+ }
// Overload of FixedArray::front() to return a reference to the first element
// of a fixed array of const values.
- const_reference front() const {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[0];
- }
+ const_reference front() const {
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[0];
+ }
// FixedArray::back()
//
// Returns a reference to the last element of the fixed array.
- reference back() {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[size() - 1];
- }
+ reference back() {
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[size() - 1];
+ }
// Overload of FixedArray::back() to return a reference to the last element
// of a fixed array of const values.
- const_reference back() const {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[size() - 1];
- }
+ const_reference back() const {
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[size() - 1];
+ }
// FixedArray::begin()
//
@@ -418,15 +418,15 @@ class FixedArray {
void AnnotateConstruct(size_type n);
void AnnotateDestruct(size_type n);
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
void* RedzoneBegin() { return &redzone_begin_; }
void* RedzoneEnd() { return &redzone_end_ + 1; }
-#endif // ABSL_HAVE_ADDRESS_SANITIZER
+#endif // ABSL_HAVE_ADDRESS_SANITIZER
private:
- ABSL_ADDRESS_SANITIZER_REDZONE(redzone_begin_);
+ ABSL_ADDRESS_SANITIZER_REDZONE(redzone_begin_);
alignas(StorageElement) char buff_[sizeof(StorageElement[inline_elements])];
- ABSL_ADDRESS_SANITIZER_REDZONE(redzone_end_);
+ ABSL_ADDRESS_SANITIZER_REDZONE(redzone_end_);
};
class EmptyInlinedStorage {
@@ -499,26 +499,26 @@ constexpr typename FixedArray<T, N, A>::size_type
template <typename T, size_t N, typename A>
void FixedArray<T, N, A>::NonEmptyInlinedStorage::AnnotateConstruct(
typename FixedArray<T, N, A>::size_type n) {
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
if (!n) return;
- ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(data(), RedzoneEnd(), RedzoneEnd(),
- data() + n);
- ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(RedzoneBegin(), data(), data(),
- RedzoneBegin());
-#endif // ABSL_HAVE_ADDRESS_SANITIZER
+ ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(data(), RedzoneEnd(), RedzoneEnd(),
+ data() + n);
+ ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(RedzoneBegin(), data(), data(),
+ RedzoneBegin());
+#endif // ABSL_HAVE_ADDRESS_SANITIZER
static_cast<void>(n); // Mark used when not in asan mode
}
template <typename T, size_t N, typename A>
void FixedArray<T, N, A>::NonEmptyInlinedStorage::AnnotateDestruct(
typename FixedArray<T, N, A>::size_type n) {
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
if (!n) return;
- ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(data(), RedzoneEnd(), data() + n,
- RedzoneEnd());
- ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(RedzoneBegin(), data(), RedzoneBegin(),
- data());
-#endif // ABSL_HAVE_ADDRESS_SANITIZER
+ ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(data(), RedzoneEnd(), data() + n,
+ RedzoneEnd());
+ ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(RedzoneBegin(), data(), RedzoneBegin(),
+ data());
+#endif // ABSL_HAVE_ADDRESS_SANITIZER
static_cast<void>(n); // Mark used when not in asan mode
}
ABSL_NAMESPACE_END
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h
index eb3f09f06d..94e84ab363 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h
@@ -234,8 +234,8 @@ class flat_hash_map : public y_absl::container_internal::raw_hash_map<
//
// size_type erase(const key_type& key):
//
- // Erases the element with the matching key, if it exists, returning the
- // number of elements erased (0 or 1).
+ // Erases the element with the matching key, if it exists, returning the
+ // number of elements erased (0 or 1).
using Base::erase;
// flat_hash_map::insert()
@@ -384,11 +384,11 @@ class flat_hash_map : public y_absl::container_internal::raw_hash_map<
// key value and returns a node handle owning that extracted data. If the
// `flat_hash_map` does not contain an element with a matching key, this
// function returns an empty node handle.
- //
- // NOTE: when compiled in an earlier version of C++ than C++17,
- // `node_type::key()` returns a const reference to the key instead of a
- // mutable reference. We cannot safely return a mutable reference without
- // std::launder (which is not available before C++17).
+ //
+ // NOTE: when compiled in an earlier version of C++ than C++17,
+ // `node_type::key()` returns a const reference to the key instead of a
+ // mutable reference. We cannot safely return a mutable reference without
+ // std::launder (which is not available before C++17).
using Base::extract;
// flat_hash_map::merge()
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h
index 23fe02a950..576bd2808d 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h
@@ -227,8 +227,8 @@ class flat_hash_set
//
// size_type erase(const key_type& key):
//
- // Erases the element with the matching key, if it exists, returning the
- // number of elements erased (0 or 1).
+ // Erases the element with the matching key, if it exists, returning the
+ // number of elements erased (0 or 1).
using Base::erase;
// flat_hash_set::insert()
@@ -324,7 +324,7 @@ class flat_hash_set
// flat_hash_set::merge()
//
- // Extracts elements from a given `source` flat hash set into this
+ // Extracts elements from a given `source` flat hash set into this
// `flat_hash_set`. If the destination `flat_hash_set` already contains an
// element with an equivalent key, that element is not extracted.
using Base::merge;
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h
index 34af121cf7..1b177f8197 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h
@@ -48,7 +48,7 @@
#include "y_absl/algorithm/algorithm.h"
#include "y_absl/base/internal/throw_delegate.h"
-#include "y_absl/base/macros.h"
+#include "y_absl/base/macros.h"
#include "y_absl/base/optimization.h"
#include "y_absl/base/port.h"
#include "y_absl/container/internal/inlined_vector.h"
@@ -64,7 +64,7 @@ ABSL_NAMESPACE_BEGIN
// `std::vector` for use cases where the vector's size is sufficiently small
// that it can be inlined. If the inlined vector does grow beyond its estimated
// capacity, it will trigger an initial allocation on the heap, and will behave
-// as a `std::vector`. The API of the `y_absl::InlinedVector` within this file is
+// as a `std::vector`. The API of the `y_absl::InlinedVector` within this file is
// designed to cover the same API footprint as covered by `std::vector`.
template <typename T, size_t N, typename A = std::allocator<T>>
class InlinedVector {
@@ -174,13 +174,13 @@ class InlinedVector {
// provided `allocator`.
InlinedVector(const InlinedVector& other, const allocator_type& allocator)
: storage_(allocator) {
- if (other.empty()) {
- // Empty; nothing to do.
+ if (other.empty()) {
+ // Empty; nothing to do.
} else if (IsMemcpyOk<A>::value && !other.storage_.GetIsAllocated()) {
- // Memcpy-able and do not need allocation.
+ // Memcpy-able and do not need allocation.
storage_.MemcpyFrom(other.storage_);
} else {
- storage_.InitFrom(other.storage_);
+ storage_.InitFrom(other.storage_);
}
}
@@ -319,14 +319,14 @@ class InlinedVector {
//
// Returns a `reference` to the `i`th element of the inlined vector.
reference operator[](size_type i) {
- ABSL_HARDENING_ASSERT(i < size());
+ ABSL_HARDENING_ASSERT(i < size());
return data()[i];
}
// Overload of `InlinedVector::operator[](...)` that returns a
// `const_reference` to the `i`th element of the inlined vector.
const_reference operator[](size_type i) const {
- ABSL_HARDENING_ASSERT(i < size());
+ ABSL_HARDENING_ASSERT(i < size());
return data()[i];
}
@@ -361,30 +361,30 @@ class InlinedVector {
//
// Returns a `reference` to the first element of the inlined vector.
reference front() {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[0];
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[0];
}
// Overload of `InlinedVector::front()` that returns a `const_reference` to
// the first element of the inlined vector.
const_reference front() const {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[0];
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[0];
}
// `InlinedVector::back()`
//
// Returns a `reference` to the last element of the inlined vector.
reference back() {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[size() - 1];
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[size() - 1];
}
// Overload of `InlinedVector::back()` that returns a `const_reference` to the
// last element of the inlined vector.
const_reference back() const {
- ABSL_HARDENING_ASSERT(!empty());
- return data()[size() - 1];
+ ABSL_HARDENING_ASSERT(!empty());
+ return data()[size() - 1];
}
// `InlinedVector::begin()`
@@ -535,7 +535,7 @@ class InlinedVector {
void assign(InputIterator first, InputIterator last) {
size_type i = 0;
for (; i < size() && first != last; ++i, static_cast<void>(++first)) {
- data()[i] = *first;
+ data()[i] = *first;
}
erase(data() + i, data() + size());
@@ -546,12 +546,12 @@ class InlinedVector {
//
// Resizes the inlined vector to contain `n` elements.
//
- // NOTE: If `n` is smaller than `size()`, extra elements are destroyed. If `n`
+ // NOTE: If `n` is smaller than `size()`, extra elements are destroyed. If `n`
// is larger than `size()`, new elements are value-initialized.
- void resize(size_type n) {
- ABSL_HARDENING_ASSERT(n <= max_size());
+ void resize(size_type n) {
+ ABSL_HARDENING_ASSERT(n <= max_size());
storage_.Resize(DefaultValueAdapter<A>(), n);
- }
+ }
// Overload of `InlinedVector::resize(...)` that resizes the inlined vector to
// contain `n` elements.
@@ -559,7 +559,7 @@ class InlinedVector {
// NOTE: if `n` is smaller than `size()`, extra elements are destroyed. If `n`
// is larger than `size()`, new elements are copied-constructed from `v`.
void resize(size_type n, const_reference v) {
- ABSL_HARDENING_ASSERT(n <= max_size());
+ ABSL_HARDENING_ASSERT(n <= max_size());
storage_.Resize(CopyValueAdapter<A>(std::addressof(v)), n);
}
@@ -581,8 +581,8 @@ class InlinedVector {
// of `v` starting at `pos`, returning an `iterator` pointing to the first of
// the newly inserted elements.
iterator insert(const_iterator pos, size_type n, const_reference v) {
- ABSL_HARDENING_ASSERT(pos >= begin());
- ABSL_HARDENING_ASSERT(pos <= end());
+ ABSL_HARDENING_ASSERT(pos >= begin());
+ ABSL_HARDENING_ASSERT(pos <= end());
if (ABSL_PREDICT_TRUE(n != 0)) {
value_type dealias = v;
@@ -609,8 +609,8 @@ class InlinedVector {
EnableIfAtLeastForwardIterator<ForwardIterator> = 0>
iterator insert(const_iterator pos, ForwardIterator first,
ForwardIterator last) {
- ABSL_HARDENING_ASSERT(pos >= begin());
- ABSL_HARDENING_ASSERT(pos <= end());
+ ABSL_HARDENING_ASSERT(pos >= begin());
+ ABSL_HARDENING_ASSERT(pos <= end());
if (ABSL_PREDICT_TRUE(first != last)) {
return storage_.Insert(pos,
@@ -629,8 +629,8 @@ class InlinedVector {
template <typename InputIterator,
DisableIfAtLeastForwardIterator<InputIterator> = 0>
iterator insert(const_iterator pos, InputIterator first, InputIterator last) {
- ABSL_HARDENING_ASSERT(pos >= begin());
- ABSL_HARDENING_ASSERT(pos <= end());
+ ABSL_HARDENING_ASSERT(pos >= begin());
+ ABSL_HARDENING_ASSERT(pos <= end());
size_type index = std::distance(cbegin(), pos);
for (size_type i = index; first != last; ++i, static_cast<void>(++first)) {
@@ -646,8 +646,8 @@ class InlinedVector {
// `pos`, returning an `iterator` pointing to the newly emplaced element.
template <typename... Args>
iterator emplace(const_iterator pos, Args&&... args) {
- ABSL_HARDENING_ASSERT(pos >= begin());
- ABSL_HARDENING_ASSERT(pos <= end());
+ ABSL_HARDENING_ASSERT(pos >= begin());
+ ABSL_HARDENING_ASSERT(pos <= end());
value_type dealias(std::forward<Args>(args)...);
return storage_.Insert(pos,
@@ -680,7 +680,7 @@ class InlinedVector {
//
// Destroys the element at `back()`, reducing the size by `1`.
void pop_back() noexcept {
- ABSL_HARDENING_ASSERT(!empty());
+ ABSL_HARDENING_ASSERT(!empty());
AllocatorTraits<A>::destroy(storage_.GetAllocator(), data() + (size() - 1));
storage_.SubtractSize(1);
@@ -693,8 +693,8 @@ class InlinedVector {
//
// NOTE: may return `end()`, which is not dereferencable.
iterator erase(const_iterator pos) {
- ABSL_HARDENING_ASSERT(pos >= begin());
- ABSL_HARDENING_ASSERT(pos < end());
+ ABSL_HARDENING_ASSERT(pos >= begin());
+ ABSL_HARDENING_ASSERT(pos < end());
return storage_.Erase(pos, pos + 1);
}
@@ -705,9 +705,9 @@ class InlinedVector {
//
// NOTE: may return `end()`, which is not dereferencable.
iterator erase(const_iterator from, const_iterator to) {
- ABSL_HARDENING_ASSERT(from >= begin());
- ABSL_HARDENING_ASSERT(from <= to);
- ABSL_HARDENING_ASSERT(to <= end());
+ ABSL_HARDENING_ASSERT(from >= begin());
+ ABSL_HARDENING_ASSERT(from <= to);
+ ABSL_HARDENING_ASSERT(to <= end());
if (ABSL_PREDICT_TRUE(from != to)) {
return storage_.Erase(from, to);
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/absl_hashtablez_sampler/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/absl_hashtablez_sampler/ya.make
index 54874c0466..f0651b0b41 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/absl_hashtablez_sampler/ya.make
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/absl_hashtablez_sampler/ya.make
@@ -1,49 +1,49 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-OWNER(
- somov
- g:cpp-contrib
-)
-
-LICENSE(Apache-2.0)
-
-PEERDIR(
- contrib/restricted/abseil-cpp-tstring/y_absl/base
+# Generated by devtools/yamaker.
+
+LIBRARY()
+
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ somov
+ g:cpp-contrib
+)
+
+LICENSE(Apache-2.0)
+
+PEERDIR(
+ contrib/restricted/abseil-cpp-tstring/y_absl/base
contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc
- contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging
- contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait
- contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate
- contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity
+ contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging
+ contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait
+ contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate
+ contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity
contrib/restricted/abseil-cpp-tstring/y_absl/debugging
contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace
contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize
contrib/restricted/abseil-cpp-tstring/y_absl/demangle
- contrib/restricted/abseil-cpp-tstring/y_absl/numeric
+ contrib/restricted/abseil-cpp-tstring/y_absl/numeric
contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased
- contrib/restricted/abseil-cpp-tstring/y_absl/strings
+ contrib/restricted/abseil-cpp-tstring/y_absl/strings
contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal
contrib/restricted/abseil-cpp-tstring/y_absl/synchronization
contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal
contrib/restricted/abseil-cpp-tstring/y_absl/time
contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time
contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone
-)
-
-ADDINCL(
- GLOBAL contrib/restricted/abseil-cpp-tstring
-)
-
-NO_COMPILER_WARNINGS()
-
+)
+
+ADDINCL(
+ GLOBAL contrib/restricted/abseil-cpp-tstring
+)
+
+NO_COMPILER_WARNINGS()
+
SRCDIR(contrib/restricted/abseil-cpp-tstring/y_absl/container/internal)
-
-SRCS(
+
+SRCS(
hashtablez_sampler.cc
hashtablez_sampler_force_weak_definition.cc
-)
-
-END()
+)
+
+END()
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h
index a249260811..40e81d5cae 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h
@@ -65,7 +65,7 @@
#include "y_absl/container/internal/layout.h"
#include "y_absl/memory/memory.h"
#include "y_absl/meta/type_traits.h"
-#include "y_absl/strings/cord.h"
+#include "y_absl/strings/cord.h"
#include "y_absl/strings/string_view.h"
#include "y_absl/types/compare.h"
#include "y_absl/utility/utility.h"
@@ -99,19 +99,19 @@ struct StringBtreeDefaultLess {
y_absl::string_view rhs) const {
return compare_internal::compare_result_as_ordering(lhs.compare(rhs));
}
- StringBtreeDefaultLess(std::less<y_absl::Cord>) {} // NOLINT
- y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
- const y_absl::Cord &rhs) const {
- return compare_internal::compare_result_as_ordering(lhs.Compare(rhs));
- }
- y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
- y_absl::string_view rhs) const {
- return compare_internal::compare_result_as_ordering(lhs.Compare(rhs));
- }
- y_absl::weak_ordering operator()(y_absl::string_view lhs,
- const y_absl::Cord &rhs) const {
- return compare_internal::compare_result_as_ordering(-rhs.Compare(lhs));
- }
+ StringBtreeDefaultLess(std::less<y_absl::Cord>) {} // NOLINT
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(lhs.Compare(rhs));
+ }
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ y_absl::string_view rhs) const {
+ return compare_internal::compare_result_as_ordering(lhs.Compare(rhs));
+ }
+ y_absl::weak_ordering operator()(y_absl::string_view lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(-rhs.Compare(lhs));
+ }
};
struct StringBtreeDefaultGreater {
@@ -131,30 +131,30 @@ struct StringBtreeDefaultGreater {
y_absl::string_view rhs) const {
return compare_internal::compare_result_as_ordering(rhs.compare(lhs));
}
- StringBtreeDefaultGreater(std::greater<y_absl::Cord>) {} // NOLINT
- y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
- const y_absl::Cord &rhs) const {
- return compare_internal::compare_result_as_ordering(rhs.Compare(lhs));
- }
- y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
- y_absl::string_view rhs) const {
- return compare_internal::compare_result_as_ordering(-lhs.Compare(rhs));
- }
- y_absl::weak_ordering operator()(y_absl::string_view lhs,
- const y_absl::Cord &rhs) const {
- return compare_internal::compare_result_as_ordering(rhs.Compare(lhs));
- }
+ StringBtreeDefaultGreater(std::greater<y_absl::Cord>) {} // NOLINT
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(rhs.Compare(lhs));
+ }
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ y_absl::string_view rhs) const {
+ return compare_internal::compare_result_as_ordering(-lhs.Compare(rhs));
+ }
+ y_absl::weak_ordering operator()(y_absl::string_view lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(rhs.Compare(lhs));
+ }
};
// A helper class to convert a boolean comparison into a three-way "compare-to"
-// comparison that returns an `y_absl::weak_ordering`. This helper
+// comparison that returns an `y_absl::weak_ordering`. This helper
// class is specialized for less<TString>, greater<TString>,
-// less<string_view>, greater<string_view>, less<y_absl::Cord>, and
-// greater<y_absl::Cord>.
+// less<string_view>, greater<string_view>, less<y_absl::Cord>, and
+// greater<y_absl::Cord>.
//
// key_compare_to_adapter is provided so that btree users
// automatically get the more efficient compare-to code when using common
-// Abseil string types with common comparison functors.
+// Abseil string types with common comparison functors.
// These string-like specializations also turn on heterogeneous lookup by
// default.
template <typename Compare>
@@ -182,54 +182,54 @@ struct key_compare_to_adapter<std::greater<y_absl::string_view>> {
using type = StringBtreeDefaultGreater;
};
-template <>
-struct key_compare_to_adapter<std::less<y_absl::Cord>> {
- using type = StringBtreeDefaultLess;
-};
-
-template <>
-struct key_compare_to_adapter<std::greater<y_absl::Cord>> {
- using type = StringBtreeDefaultGreater;
-};
-
-// Detects an 'absl_btree_prefer_linear_node_search' member. This is
-// a protocol used as an opt-in or opt-out of linear search.
-//
-// For example, this would be useful for key types that wrap an integer
-// and define their own cheap operator<(). For example:
-//
-// class K {
-// public:
-// using absl_btree_prefer_linear_node_search = std::true_type;
-// ...
-// private:
-// friend bool operator<(K a, K b) { return a.k_ < b.k_; }
-// int k_;
-// };
-//
-// btree_map<K, V> m; // Uses linear search
-//
-// If T has the preference tag, then it has a preference.
-// Btree will use the tag's truth value.
-template <typename T, typename = void>
-struct has_linear_node_search_preference : std::false_type {};
-template <typename T, typename = void>
-struct prefers_linear_node_search : std::false_type {};
-template <typename T>
-struct has_linear_node_search_preference<
- T, y_absl::void_t<typename T::absl_btree_prefer_linear_node_search>>
- : std::true_type {};
-template <typename T>
-struct prefers_linear_node_search<
- T, y_absl::void_t<typename T::absl_btree_prefer_linear_node_search>>
- : T::absl_btree_prefer_linear_node_search {};
-
+template <>
+struct key_compare_to_adapter<std::less<y_absl::Cord>> {
+ using type = StringBtreeDefaultLess;
+};
+
+template <>
+struct key_compare_to_adapter<std::greater<y_absl::Cord>> {
+ using type = StringBtreeDefaultGreater;
+};
+
+// Detects an 'absl_btree_prefer_linear_node_search' member. This is
+// a protocol used as an opt-in or opt-out of linear search.
+//
+// For example, this would be useful for key types that wrap an integer
+// and define their own cheap operator<(). For example:
+//
+// class K {
+// public:
+// using absl_btree_prefer_linear_node_search = std::true_type;
+// ...
+// private:
+// friend bool operator<(K a, K b) { return a.k_ < b.k_; }
+// int k_;
+// };
+//
+// btree_map<K, V> m; // Uses linear search
+//
+// If T has the preference tag, then it has a preference.
+// Btree will use the tag's truth value.
+template <typename T, typename = void>
+struct has_linear_node_search_preference : std::false_type {};
+template <typename T, typename = void>
+struct prefers_linear_node_search : std::false_type {};
+template <typename T>
+struct has_linear_node_search_preference<
+ T, y_absl::void_t<typename T::absl_btree_prefer_linear_node_search>>
+ : std::true_type {};
+template <typename T>
+struct prefers_linear_node_search<
+ T, y_absl::void_t<typename T::absl_btree_prefer_linear_node_search>>
+ : T::absl_btree_prefer_linear_node_search {};
+
template <typename Key, typename Compare, typename Alloc, int TargetNodeSize,
bool Multi, typename SlotPolicy>
struct common_params {
using original_key_compare = Compare;
- // If Compare is a common comparator for a string-like type, then we adapt it
+ // If Compare is a common comparator for a string-like type, then we adapt it
// to use heterogeneous lookup and to be a key-compare-to comparator.
using key_compare = typename key_compare_to_adapter<Compare>::type;
// A type which indicates if we have a key-compare-to functor or a plain old
@@ -250,23 +250,23 @@ struct common_params {
using reference = value_type &;
using const_reference = const value_type &;
- // For the given lookup key type, returns whether we can have multiple
- // equivalent keys in the btree. If this is a multi-container, then we can.
- // Otherwise, we can have multiple equivalent keys only if all of the
- // following conditions are met:
- // - The comparator is transparent.
- // - The lookup key type is not the same as key_type.
- // - The comparator is not a StringBtreeDefault{Less,Greater} comparator
- // that we know has the same equivalence classes for all lookup types.
- template <typename LookupKey>
- constexpr static bool can_have_multiple_equivalent_keys() {
- return Multi ||
- (IsTransparent<key_compare>::value &&
- !std::is_same<LookupKey, Key>::value &&
- !std::is_same<key_compare, StringBtreeDefaultLess>::value &&
- !std::is_same<key_compare, StringBtreeDefaultGreater>::value);
- }
-
+ // For the given lookup key type, returns whether we can have multiple
+ // equivalent keys in the btree. If this is a multi-container, then we can.
+ // Otherwise, we can have multiple equivalent keys only if all of the
+ // following conditions are met:
+ // - The comparator is transparent.
+ // - The lookup key type is not the same as key_type.
+ // - The comparator is not a StringBtreeDefault{Less,Greater} comparator
+ // that we know has the same equivalence classes for all lookup types.
+ template <typename LookupKey>
+ constexpr static bool can_have_multiple_equivalent_keys() {
+ return Multi ||
+ (IsTransparent<key_compare>::value &&
+ !std::is_same<LookupKey, Key>::value &&
+ !std::is_same<key_compare, StringBtreeDefaultLess>::value &&
+ !std::is_same<key_compare, StringBtreeDefaultGreater>::value);
+ }
+
enum {
kTargetNodeSize = TargetNodeSize,
@@ -348,17 +348,17 @@ struct map_params : common_params<Key, Compare, Alloc, TargetNodeSize, Multi,
};
using is_map_container = std::true_type;
- template <typename V>
- static auto key(const V &value) -> decltype(value.first) {
- return value.first;
- }
- static const Key &key(const slot_type *s) { return slot_policy::key(s); }
- static const Key &key(slot_type *s) { return slot_policy::key(s); }
- // For use in node handle.
- static auto mutable_key(slot_type *s)
- -> decltype(slot_policy::mutable_key(s)) {
- return slot_policy::mutable_key(s);
- }
+ template <typename V>
+ static auto key(const V &value) -> decltype(value.first) {
+ return value.first;
+ }
+ static const Key &key(const slot_type *s) { return slot_policy::key(s); }
+ static const Key &key(slot_type *s) { return slot_policy::key(s); }
+ // For use in node handle.
+ static auto mutable_key(slot_type *s)
+ -> decltype(slot_policy::mutable_key(s)) {
+ return slot_policy::mutable_key(s);
+ }
static mapped_type &value(value_type *value) { return value->second; }
};
@@ -413,10 +413,10 @@ struct set_params : common_params<Key, Compare, Alloc, TargetNodeSize, Multi,
typename set_params::common_params::original_key_compare;
using is_map_container = std::false_type;
- template <typename V>
- static const V &key(const V &value) { return value; }
- static const Key &key(const slot_type *slot) { return *slot; }
- static const Key &key(slot_type *slot) { return *slot; }
+ template <typename V>
+ static const V &key(const V &value) { return value; }
+ static const Key &key(const slot_type *slot) { return *slot; }
+ static const Key &key(slot_type *slot) { return *slot; }
};
// An adapter class that converts a lower-bound compare into an upper-bound
@@ -426,8 +426,8 @@ struct set_params : common_params<Key, Compare, Alloc, TargetNodeSize, Multi,
template <typename Compare>
struct upper_bound_adapter {
explicit upper_bound_adapter(const Compare &c) : comp(c) {}
- template <typename K1, typename K2>
- bool operator()(const K1 &a, const K2 &b) const {
+ template <typename K1, typename K2>
+ bool operator()(const K1 &a, const K2 &b) const {
// Returns true when a is not greater than b.
return !compare_internal::compare_result_as_less_than(comp(b, a));
}
@@ -452,10 +452,10 @@ struct SearchResult {
// useful information.
template <typename V>
struct SearchResult<V, false> {
- SearchResult() {}
- explicit SearchResult(V value) : value(value) {}
- SearchResult(V value, MatchKind /*match*/) : value(value) {}
-
+ SearchResult() {}
+ explicit SearchResult(V value) : value(value) {}
+ SearchResult(V value, MatchKind /*match*/) : value(value) {}
+
V value;
static constexpr bool HasMatch() { return false; }
@@ -485,22 +485,22 @@ class btree_node {
using difference_type = typename Params::difference_type;
// Btree decides whether to use linear node search as follows:
- // - If the comparator expresses a preference, use that.
- // - If the key expresses a preference, use that.
+ // - If the comparator expresses a preference, use that.
+ // - If the key expresses a preference, use that.
// - If the key is arithmetic and the comparator is std::less or
// std::greater, choose linear.
// - Otherwise, choose binary.
// TODO(ezb): Might make sense to add condition(s) based on node-size.
using use_linear_search = std::integral_constant<
bool,
- has_linear_node_search_preference<key_compare>::value
- ? prefers_linear_node_search<key_compare>::value
- : has_linear_node_search_preference<key_type>::value
- ? prefers_linear_node_search<key_type>::value
- : std::is_arithmetic<key_type>::value &&
- (std::is_same<std::less<key_type>, key_compare>::value ||
- std::is_same<std::greater<key_type>,
- key_compare>::value)>;
+ has_linear_node_search_preference<key_compare>::value
+ ? prefers_linear_node_search<key_compare>::value
+ : has_linear_node_search_preference<key_type>::value
+ ? prefers_linear_node_search<key_type>::value
+ : std::is_arithmetic<key_type>::value &&
+ (std::is_same<std::less<key_type>, key_compare>::value ||
+ std::is_same<std::greater<key_type>,
+ key_compare>::value)>;
// This class is organized by y_absl::container_internal::Layout as if it had
// the following structure:
@@ -517,23 +517,23 @@ class btree_node {
// // is the same as the count of values.
// field_type finish;
// // The maximum number of values the node can hold. This is an integer in
- // // [1, kNodeSlots] for root leaf nodes, kNodeSlots for non-root leaf
+ // // [1, kNodeSlots] for root leaf nodes, kNodeSlots for non-root leaf
// // nodes, and kInternalNodeMaxCount (as a sentinel value) for internal
- // // nodes (even though there are still kNodeSlots values in the node).
+ // // nodes (even though there are still kNodeSlots values in the node).
// // TODO(ezb): make max_count use only 4 bits and record log2(capacity)
// // to free extra bits for is_root, etc.
// field_type max_count;
//
// // The array of values. The capacity is `max_count` for leaf nodes and
- // // kNodeSlots for internal nodes. Only the values in
+ // // kNodeSlots for internal nodes. Only the values in
// // [start, finish) have been initialized and are valid.
// slot_type values[max_count];
//
// // The array of child pointers. The keys in children[i] are all less
// // than key(i). The keys in children[i + 1] are all greater than key(i).
- // // There are 0 children for leaf nodes and kNodeSlots + 1 children for
+ // // There are 0 children for leaf nodes and kNodeSlots + 1 children for
// // internal nodes.
- // btree_node *children[kNodeSlots + 1];
+ // btree_node *children[kNodeSlots + 1];
//
// This class is only constructed by EmptyNodeType. Normally, pointers to the
// layout above are allocated, cast to btree_node*, and de-allocated within
@@ -555,62 +555,62 @@ class btree_node {
private:
using layout_type = y_absl::container_internal::Layout<btree_node *, field_type,
slot_type, btree_node *>;
- constexpr static size_type SizeWithNSlots(size_type n) {
+ constexpr static size_type SizeWithNSlots(size_type n) {
return layout_type(/*parent*/ 1,
/*position, start, finish, max_count*/ 4,
- /*slots*/ n,
+ /*slots*/ n,
/*children*/ 0)
.AllocSize();
}
// A lower bound for the overhead of fields other than values in a leaf node.
constexpr static size_type MinimumOverhead() {
- return SizeWithNSlots(1) - sizeof(value_type);
+ return SizeWithNSlots(1) - sizeof(value_type);
}
// Compute how many values we can fit onto a leaf node taking into account
// padding.
- constexpr static size_type NodeTargetSlots(const int begin, const int end) {
+ constexpr static size_type NodeTargetSlots(const int begin, const int end) {
return begin == end ? begin
- : SizeWithNSlots((begin + end) / 2 + 1) >
+ : SizeWithNSlots((begin + end) / 2 + 1) >
params_type::kTargetNodeSize
- ? NodeTargetSlots(begin, (begin + end) / 2)
- : NodeTargetSlots((begin + end) / 2 + 1, end);
+ ? NodeTargetSlots(begin, (begin + end) / 2)
+ : NodeTargetSlots((begin + end) / 2 + 1, end);
}
enum {
kTargetNodeSize = params_type::kTargetNodeSize,
- kNodeTargetSlots = NodeTargetSlots(0, params_type::kTargetNodeSize),
+ kNodeTargetSlots = NodeTargetSlots(0, params_type::kTargetNodeSize),
- // We need a minimum of 3 slots per internal node in order to perform
+ // We need a minimum of 3 slots per internal node in order to perform
// splitting (1 value for the two nodes involved in the split and 1 value
- // propagated to the parent as the delimiter for the split). For performance
- // reasons, we don't allow 3 slots-per-node due to bad worst case occupancy
- // of 1/3 (for a node, not a b-tree).
- kMinNodeSlots = 4,
-
- kNodeSlots =
- kNodeTargetSlots >= kMinNodeSlots ? kNodeTargetSlots : kMinNodeSlots,
-
+ // propagated to the parent as the delimiter for the split). For performance
+ // reasons, we don't allow 3 slots-per-node due to bad worst case occupancy
+ // of 1/3 (for a node, not a b-tree).
+ kMinNodeSlots = 4,
+
+ kNodeSlots =
+ kNodeTargetSlots >= kMinNodeSlots ? kNodeTargetSlots : kMinNodeSlots,
+
// The node is internal (i.e. is not a leaf node) if and only if `max_count`
// has this value.
kInternalNodeMaxCount = 0,
};
- // Leaves can have less than kNodeSlots values.
- constexpr static layout_type LeafLayout(const int slot_count = kNodeSlots) {
+ // Leaves can have less than kNodeSlots values.
+ constexpr static layout_type LeafLayout(const int slot_count = kNodeSlots) {
return layout_type(/*parent*/ 1,
/*position, start, finish, max_count*/ 4,
- /*slots*/ slot_count,
+ /*slots*/ slot_count,
/*children*/ 0);
}
constexpr static layout_type InternalLayout() {
return layout_type(/*parent*/ 1,
/*position, start, finish, max_count*/ 4,
- /*slots*/ kNodeSlots,
- /*children*/ kNodeSlots + 1);
+ /*slots*/ kNodeSlots,
+ /*children*/ kNodeSlots + 1);
}
- constexpr static size_type LeafSize(const int slot_count = kNodeSlots) {
- return LeafLayout(slot_count).AllocSize();
+ constexpr static size_type LeafSize(const int slot_count = kNodeSlots) {
+ return LeafLayout(slot_count).AllocSize();
}
constexpr static size_type InternalSize() {
return InternalLayout().AllocSize();
@@ -667,10 +667,10 @@ class btree_node {
}
field_type max_count() const {
// Internal nodes have max_count==kInternalNodeMaxCount.
- // Leaf nodes have max_count in [1, kNodeSlots].
+ // Leaf nodes have max_count in [1, kNodeSlots].
const field_type max_count = GetField<1>()[3];
return max_count == field_type{kInternalNodeMaxCount}
- ? field_type{kNodeSlots}
+ ? field_type{kNodeSlots}
: max_count;
}
@@ -748,7 +748,7 @@ class btree_node {
}
++s;
}
- return SearchResult<int, false>{s};
+ return SearchResult<int, false>{s};
}
// Returns the position of the first value whose key is not less than k using
@@ -783,7 +783,7 @@ class btree_node {
e = mid;
}
}
- return SearchResult<int, false>{s};
+ return SearchResult<int, false>{s};
}
// Returns the position of the first value whose key is not less than k using
@@ -792,7 +792,7 @@ class btree_node {
SearchResult<int, true> binary_search_impl(
const K &k, int s, int e, const CompareTo &comp,
std::true_type /* IsCompareTo */) const {
- if (params_type::template can_have_multiple_equivalent_keys<K>()) {
+ if (params_type::template can_have_multiple_equivalent_keys<K>()) {
MatchKind exact_match = MatchKind::kNe;
while (s != e) {
const int mid = (s + e) >> 1;
@@ -803,14 +803,14 @@ class btree_node {
e = mid;
if (c == 0) {
// Need to return the first value whose key is not less than k,
- // which requires continuing the binary search if there could be
- // multiple equivalent keys.
+ // which requires continuing the binary search if there could be
+ // multiple equivalent keys.
exact_match = MatchKind::kEq;
}
}
}
return {s, exact_match};
- } else { // Can't have multiple equivalent keys.
+ } else { // Can't have multiple equivalent keys.
while (s != e) {
const int mid = (s + e) >> 1;
const y_absl::weak_ordering c = comp(key(mid), k);
@@ -831,10 +831,10 @@ class btree_node {
template <typename... Args>
void emplace_value(size_type i, allocator_type *alloc, Args &&... args);
- // Removes the values at positions [i, i + to_erase), shifting all existing
- // values and children after that range to the left by to_erase. Clears all
- // children between [i, i + to_erase).
- void remove_values(field_type i, field_type to_erase, allocator_type *alloc);
+ // Removes the values at positions [i, i + to_erase), shifting all existing
+ // values and children after that range to the left by to_erase. Clears all
+ // children between [i, i + to_erase).
+ void remove_values(field_type i, field_type to_erase, allocator_type *alloc);
// Rebalances a node with its right sibling.
void rebalance_right_to_left(int to_move, btree_node *right,
@@ -846,87 +846,87 @@ class btree_node {
void split(int insert_position, btree_node *dest, allocator_type *alloc);
// Merges a node with its right sibling, moving all of the values and the
- // delimiting key in the parent node onto itself, and deleting the src node.
- void merge(btree_node *src, allocator_type *alloc);
+ // delimiting key in the parent node onto itself, and deleting the src node.
+ void merge(btree_node *src, allocator_type *alloc);
// Node allocation/deletion routines.
- void init_leaf(btree_node *parent, int max_count) {
- set_parent(parent);
- set_position(0);
- set_start(0);
- set_finish(0);
- set_max_count(max_count);
+ void init_leaf(btree_node *parent, int max_count) {
+ set_parent(parent);
+ set_position(0);
+ set_start(0);
+ set_finish(0);
+ set_max_count(max_count);
y_absl::container_internal::SanitizerPoisonMemoryRegion(
- start_slot(), max_count * sizeof(slot_type));
+ start_slot(), max_count * sizeof(slot_type));
}
- void init_internal(btree_node *parent) {
- init_leaf(parent, kNodeSlots);
+ void init_internal(btree_node *parent) {
+ init_leaf(parent, kNodeSlots);
// Set `max_count` to a sentinel value to indicate that this node is
// internal.
- set_max_count(kInternalNodeMaxCount);
+ set_max_count(kInternalNodeMaxCount);
y_absl::container_internal::SanitizerPoisonMemoryRegion(
- &mutable_child(start()), (kNodeSlots + 1) * sizeof(btree_node *));
+ &mutable_child(start()), (kNodeSlots + 1) * sizeof(btree_node *));
}
- static void deallocate(const size_type size, btree_node *node,
- allocator_type *alloc) {
- y_absl::container_internal::Deallocate<Alignment()>(alloc, node, size);
+ static void deallocate(const size_type size, btree_node *node,
+ allocator_type *alloc) {
+ y_absl::container_internal::Deallocate<Alignment()>(alloc, node, size);
}
- // Deletes a node and all of its children.
- static void clear_and_delete(btree_node *node, allocator_type *alloc);
-
+ // Deletes a node and all of its children.
+ static void clear_and_delete(btree_node *node, allocator_type *alloc);
+
private:
template <typename... Args>
- void value_init(const field_type i, allocator_type *alloc, Args &&... args) {
+ void value_init(const field_type i, allocator_type *alloc, Args &&... args) {
y_absl::container_internal::SanitizerUnpoisonObject(slot(i));
params_type::construct(alloc, slot(i), std::forward<Args>(args)...);
}
- void value_destroy(const field_type i, allocator_type *alloc) {
+ void value_destroy(const field_type i, allocator_type *alloc) {
params_type::destroy(alloc, slot(i));
y_absl::container_internal::SanitizerPoisonObject(slot(i));
}
- void value_destroy_n(const field_type i, const field_type n,
- allocator_type *alloc) {
- for (slot_type *s = slot(i), *end = slot(i + n); s != end; ++s) {
- params_type::destroy(alloc, s);
- y_absl::container_internal::SanitizerPoisonObject(s);
- }
- }
-
- static void transfer(slot_type *dest, slot_type *src, allocator_type *alloc) {
- y_absl::container_internal::SanitizerUnpoisonObject(dest);
- params_type::transfer(alloc, dest, src);
- y_absl::container_internal::SanitizerPoisonObject(src);
- }
-
- // Transfers value from slot `src_i` in `src_node` to slot `dest_i` in `this`.
- void transfer(const size_type dest_i, const size_type src_i,
- btree_node *src_node, allocator_type *alloc) {
- transfer(slot(dest_i), src_node->slot(src_i), alloc);
- }
-
- // Transfers `n` values starting at value `src_i` in `src_node` into the
- // values starting at value `dest_i` in `this`.
- void transfer_n(const size_type n, const size_type dest_i,
- const size_type src_i, btree_node *src_node,
- allocator_type *alloc) {
- for (slot_type *src = src_node->slot(src_i), *end = src + n,
- *dest = slot(dest_i);
+ void value_destroy_n(const field_type i, const field_type n,
+ allocator_type *alloc) {
+ for (slot_type *s = slot(i), *end = slot(i + n); s != end; ++s) {
+ params_type::destroy(alloc, s);
+ y_absl::container_internal::SanitizerPoisonObject(s);
+ }
+ }
+
+ static void transfer(slot_type *dest, slot_type *src, allocator_type *alloc) {
+ y_absl::container_internal::SanitizerUnpoisonObject(dest);
+ params_type::transfer(alloc, dest, src);
+ y_absl::container_internal::SanitizerPoisonObject(src);
+ }
+
+ // Transfers value from slot `src_i` in `src_node` to slot `dest_i` in `this`.
+ void transfer(const size_type dest_i, const size_type src_i,
+ btree_node *src_node, allocator_type *alloc) {
+ transfer(slot(dest_i), src_node->slot(src_i), alloc);
+ }
+
+ // Transfers `n` values starting at value `src_i` in `src_node` into the
+ // values starting at value `dest_i` in `this`.
+ void transfer_n(const size_type n, const size_type dest_i,
+ const size_type src_i, btree_node *src_node,
+ allocator_type *alloc) {
+ for (slot_type *src = src_node->slot(src_i), *end = src + n,
+ *dest = slot(dest_i);
src != end; ++src, ++dest) {
- transfer(dest, src, alloc);
+ transfer(dest, src, alloc);
}
}
- // Same as above, except that we start at the end and work our way to the
- // beginning.
- void transfer_n_backward(const size_type n, const size_type dest_i,
- const size_type src_i, btree_node *src_node,
- allocator_type *alloc) {
- for (slot_type *src = src_node->slot(src_i + n - 1), *end = src - n,
- *dest = slot(dest_i + n - 1);
- src != end; --src, --dest) {
- transfer(dest, src, alloc);
+ // Same as above, except that we start at the end and work our way to the
+ // beginning.
+ void transfer_n_backward(const size_type n, const size_type dest_i,
+ const size_type src_i, btree_node *src_node,
+ allocator_type *alloc) {
+ for (slot_type *src = src_node->slot(src_i + n - 1), *end = src - n,
+ *dest = slot(dest_i + n - 1);
+ src != end; --src, --dest) {
+ transfer(dest, src, alloc);
}
}
@@ -943,7 +943,7 @@ struct btree_iterator {
using key_type = typename Node::key_type;
using size_type = typename Node::size_type;
using params_type = typename Node::params_type;
- using is_map_container = typename params_type::is_map_container;
+ using is_map_container = typename params_type::is_map_container;
using node_type = Node;
using normal_node = typename std::remove_const<Node>::type;
@@ -955,7 +955,7 @@ struct btree_iterator {
using slot_type = typename params_type::slot_type;
using iterator =
- btree_iterator<normal_node, normal_reference, normal_pointer>;
+ btree_iterator<normal_node, normal_reference, normal_pointer>;
using const_iterator =
btree_iterator<const_node, const_reference, const_pointer>;
@@ -972,19 +972,19 @@ struct btree_iterator {
btree_iterator(Node *n, int p) : node(n), position(p) {}
// NOTE: this SFINAE allows for implicit conversions from iterator to
- // const_iterator, but it specifically avoids hiding the copy constructor so
- // that the trivial one will be used when possible.
+ // const_iterator, but it specifically avoids hiding the copy constructor so
+ // that the trivial one will be used when possible.
template <typename N, typename R, typename P,
y_absl::enable_if_t<
std::is_same<btree_iterator<N, R, P>, iterator>::value &&
std::is_same<btree_iterator, const_iterator>::value,
int> = 0>
- btree_iterator(const btree_iterator<N, R, P> other) // NOLINT
- : node(other.node), position(other.position) {}
+ btree_iterator(const btree_iterator<N, R, P> other) // NOLINT
+ : node(other.node), position(other.position) {}
private:
// This SFINAE allows explicit conversions from const_iterator to
- // iterator, but also avoids hiding the copy constructor.
+ // iterator, but also avoids hiding the copy constructor.
// NOTE: the const_cast is safe because this constructor is only called by
// non-const methods and the container owns the nodes.
template <typename N, typename R, typename P,
@@ -992,8 +992,8 @@ struct btree_iterator {
std::is_same<btree_iterator<N, R, P>, const_iterator>::value &&
std::is_same<btree_iterator, iterator>::value,
int> = 0>
- explicit btree_iterator(const btree_iterator<N, R, P> other)
- : node(const_cast<node_type *>(other.node)), position(other.position) {}
+ explicit btree_iterator(const btree_iterator<N, R, P> other)
+ : node(const_cast<node_type *>(other.node)), position(other.position) {}
// Increment/decrement the iterator.
void increment() {
@@ -1013,27 +1013,27 @@ struct btree_iterator {
void decrement_slow();
public:
- bool operator==(const iterator &other) const {
- return node == other.node && position == other.position;
+ bool operator==(const iterator &other) const {
+ return node == other.node && position == other.position;
}
- bool operator==(const const_iterator &other) const {
- return node == other.node && position == other.position;
- }
- bool operator!=(const iterator &other) const {
- return node != other.node || position != other.position;
- }
- bool operator!=(const const_iterator &other) const {
- return node != other.node || position != other.position;
+ bool operator==(const const_iterator &other) const {
+ return node == other.node && position == other.position;
}
+ bool operator!=(const iterator &other) const {
+ return node != other.node || position != other.position;
+ }
+ bool operator!=(const const_iterator &other) const {
+ return node != other.node || position != other.position;
+ }
// Accessors for the key/value the iterator is pointing at.
- reference operator*() const {
- ABSL_HARDENING_ASSERT(node != nullptr);
- ABSL_HARDENING_ASSERT(node->start() <= position);
- ABSL_HARDENING_ASSERT(node->finish() > position);
- return node->value(position);
- }
- pointer operator->() const { return &operator*(); }
+ reference operator*() const {
+ ABSL_HARDENING_ASSERT(node != nullptr);
+ ABSL_HARDENING_ASSERT(node->start() <= position);
+ ABSL_HARDENING_ASSERT(node->finish() > position);
+ return node->value(position);
+ }
+ pointer operator->() const { return &operator*(); }
btree_iterator &operator++() {
increment();
@@ -1055,8 +1055,8 @@ struct btree_iterator {
}
private:
- friend iterator;
- friend const_iterator;
+ friend iterator;
+ friend const_iterator;
template <typename Params>
friend class btree;
template <typename Tree>
@@ -1076,8 +1076,8 @@ struct btree_iterator {
// The node in the tree the iterator is pointing at.
Node *node;
// The position within the node of the tree the iterator is pointing at.
- // NOTE: this is an int rather than a field_type because iterators can point
- // to invalid positions (such as -1) in certain circumstances.
+ // NOTE: this is an int rather than a field_type because iterators can point
+ // to invalid positions (such as -1) in certain circumstances.
int position;
};
@@ -1085,8 +1085,8 @@ template <typename Params>
class btree {
using node_type = btree_node<Params>;
using is_key_compare_to = typename Params::is_key_compare_to;
- using init_type = typename Params::init_type;
- using field_type = typename node_type::field_type;
+ using init_type = typename Params::init_type;
+ using field_type = typename node_type::field_type;
// We use a static empty node for the root/leftmost/rightmost of empty btrees
// in order to avoid branching in begin()/end().
@@ -1121,9 +1121,9 @@ class btree {
#endif
}
- enum : uint32_t {
- kNodeSlots = node_type::kNodeSlots,
- kMinNodeValues = kNodeSlots / 2,
+ enum : uint32_t {
+ kNodeSlots = node_type::kNodeSlots,
+ kMinNodeValues = kNodeSlots / 2,
};
struct node_stats {
@@ -1131,9 +1131,9 @@ class btree {
node_stats(size_type l, size_type i) : leaf_nodes(l), internal_nodes(i) {}
- node_stats &operator+=(const node_stats &other) {
- leaf_nodes += other.leaf_nodes;
- internal_nodes += other.internal_nodes;
+ node_stats &operator+=(const node_stats &other) {
+ leaf_nodes += other.leaf_nodes;
+ internal_nodes += other.internal_nodes;
return *this;
}
@@ -1154,8 +1154,8 @@ class btree {
using const_reference = typename Params::const_reference;
using pointer = typename Params::pointer;
using const_pointer = typename Params::const_pointer;
- using iterator =
- typename btree_iterator<node_type, reference, pointer>::iterator;
+ using iterator =
+ typename btree_iterator<node_type, reference, pointer>::iterator;
using const_iterator = typename iterator::const_iterator;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
@@ -1167,47 +1167,47 @@ class btree {
private:
// For use in copy_or_move_values_in_order.
- const value_type &maybe_move_from_iterator(const_iterator it) { return *it; }
- value_type &&maybe_move_from_iterator(iterator it) {
- // This is a destructive operation on the other container so it's safe for
- // us to const_cast and move from the keys here even if it's a set.
- return std::move(const_cast<value_type &>(*it));
- }
+ const value_type &maybe_move_from_iterator(const_iterator it) { return *it; }
+ value_type &&maybe_move_from_iterator(iterator it) {
+ // This is a destructive operation on the other container so it's safe for
+ // us to const_cast and move from the keys here even if it's a set.
+ return std::move(const_cast<value_type &>(*it));
+ }
// Copies or moves (depending on the template parameter) the values in
- // other into this btree in their order in other. This btree must be empty
- // before this method is called. This method is used in copy construction,
- // copy assignment, and move assignment.
+ // other into this btree in their order in other. This btree must be empty
+ // before this method is called. This method is used in copy construction,
+ // copy assignment, and move assignment.
template <typename Btree>
- void copy_or_move_values_in_order(Btree &other);
+ void copy_or_move_values_in_order(Btree &other);
// Validates that various assumptions/requirements are true at compile time.
constexpr static bool static_assert_validation();
public:
- btree(const key_compare &comp, const allocator_type &alloc)
- : root_(comp, alloc, EmptyNode()), rightmost_(EmptyNode()), size_(0) {}
-
- btree(const btree &other) : btree(other, other.allocator()) {}
- btree(const btree &other, const allocator_type &alloc)
- : btree(other.key_comp(), alloc) {
- copy_or_move_values_in_order(other);
- }
- btree(btree &&other) noexcept
- : root_(std::move(other.root_)),
- rightmost_(y_absl::exchange(other.rightmost_, EmptyNode())),
- size_(y_absl::exchange(other.size_, 0)) {
- other.mutable_root() = EmptyNode();
- }
- btree(btree &&other, const allocator_type &alloc)
- : btree(other.key_comp(), alloc) {
- if (alloc == other.allocator()) {
- swap(other);
- } else {
- // Move values from `other` one at a time when allocators are different.
- copy_or_move_values_in_order(other);
- }
- }
+ btree(const key_compare &comp, const allocator_type &alloc)
+ : root_(comp, alloc, EmptyNode()), rightmost_(EmptyNode()), size_(0) {}
+
+ btree(const btree &other) : btree(other, other.allocator()) {}
+ btree(const btree &other, const allocator_type &alloc)
+ : btree(other.key_comp(), alloc) {
+ copy_or_move_values_in_order(other);
+ }
+ btree(btree &&other) noexcept
+ : root_(std::move(other.root_)),
+ rightmost_(y_absl::exchange(other.rightmost_, EmptyNode())),
+ size_(y_absl::exchange(other.size_, 0)) {
+ other.mutable_root() = EmptyNode();
+ }
+ btree(btree &&other, const allocator_type &alloc)
+ : btree(other.key_comp(), alloc) {
+ if (alloc == other.allocator()) {
+ swap(other);
+ } else {
+ // Move values from `other` one at a time when allocators are different.
+ copy_or_move_values_in_order(other);
+ }
+ }
~btree() {
// Put static_asserts in destructor to avoid triggering them before the type
@@ -1216,9 +1216,9 @@ class btree {
clear();
}
- // Assign the contents of other to *this.
- btree &operator=(const btree &other);
- btree &operator=(btree &&other) noexcept;
+ // Assign the contents of other to *this.
+ btree &operator=(const btree &other);
+ btree &operator=(btree &&other) noexcept;
iterator begin() { return iterator(leftmost()); }
const_iterator begin() const { return const_iterator(leftmost()); }
@@ -1235,23 +1235,23 @@ class btree {
return const_reverse_iterator(begin());
}
- // Finds the first element whose key is not less than `key`.
+ // Finds the first element whose key is not less than `key`.
template <typename K>
iterator lower_bound(const K &key) {
- return internal_end(internal_lower_bound(key).value);
+ return internal_end(internal_lower_bound(key).value);
}
template <typename K>
const_iterator lower_bound(const K &key) const {
- return internal_end(internal_lower_bound(key).value);
+ return internal_end(internal_lower_bound(key).value);
}
- // Finds the first element whose key is not less than `key` and also returns
- // whether that element is equal to `key`.
- template <typename K>
- std::pair<iterator, bool> lower_bound_equal(const K &key) const;
-
- // Finds the first element whose key is greater than `key`.
+ // Finds the first element whose key is not less than `key` and also returns
+ // whether that element is equal to `key`.
template <typename K>
+ std::pair<iterator, bool> lower_bound_equal(const K &key) const;
+
+ // Finds the first element whose key is greater than `key`.
+ template <typename K>
iterator upper_bound(const K &key) {
return internal_end(internal_upper_bound(key));
}
@@ -1261,21 +1261,21 @@ class btree {
}
// Finds the range of values which compare equal to key. The first member of
- // the returned pair is equal to lower_bound(key). The second member of the
- // pair is equal to upper_bound(key).
+ // the returned pair is equal to lower_bound(key). The second member of the
+ // pair is equal to upper_bound(key).
template <typename K>
- std::pair<iterator, iterator> equal_range(const K &key);
+ std::pair<iterator, iterator> equal_range(const K &key);
template <typename K>
std::pair<const_iterator, const_iterator> equal_range(const K &key) const {
- return const_cast<btree *>(this)->equal_range(key);
+ return const_cast<btree *>(this)->equal_range(key);
}
// Inserts a value into the btree only if it does not already exist. The
// boolean return value indicates whether insertion succeeded or failed.
// Requirement: if `key` already exists in the btree, does not consume `args`.
// Requirement: `key` is never referenced after consuming `args`.
- template <typename K, typename... Args>
- std::pair<iterator, bool> insert_unique(const K &key, Args &&... args);
+ template <typename K, typename... Args>
+ std::pair<iterator, bool> insert_unique(const K &key, Args &&... args);
// Inserts with hint. Checks to see if the value should be placed immediately
// before `position` in the tree. If so, then the insertion will take
@@ -1283,23 +1283,23 @@ class btree {
// logarithmic time as if a call to insert_unique() were made.
// Requirement: if `key` already exists in the btree, does not consume `args`.
// Requirement: `key` is never referenced after consuming `args`.
- template <typename K, typename... Args>
+ template <typename K, typename... Args>
std::pair<iterator, bool> insert_hint_unique(iterator position,
- const K &key,
+ const K &key,
Args &&... args);
// Insert a range of values into the btree.
- // Note: the first overload avoids constructing a value_type if the key
- // already exists in the btree.
- template <typename InputIterator,
- typename = decltype(std::declval<const key_compare &>()(
- params_type::key(*std::declval<InputIterator>()),
- std::declval<const key_type &>()))>
- void insert_iterator_unique(InputIterator b, InputIterator e, int);
- // We need the second overload for cases in which we need to construct a
- // value_type in order to compare it with the keys already in the btree.
+ // Note: the first overload avoids constructing a value_type if the key
+ // already exists in the btree.
+ template <typename InputIterator,
+ typename = decltype(std::declval<const key_compare &>()(
+ params_type::key(*std::declval<InputIterator>()),
+ std::declval<const key_type &>()))>
+ void insert_iterator_unique(InputIterator b, InputIterator e, int);
+ // We need the second overload for cases in which we need to construct a
+ // value_type in order to compare it with the keys already in the btree.
template <typename InputIterator>
- void insert_iterator_unique(InputIterator b, InputIterator e, char);
+ void insert_iterator_unique(InputIterator b, InputIterator e, char);
// Inserts a value into the btree.
template <typename ValueType>
@@ -1332,8 +1332,8 @@ class btree {
// to the element after the last erased element.
std::pair<size_type, iterator> erase_range(iterator begin, iterator end);
- // Finds an element with key equivalent to `key` or returns `end()` if `key`
- // is not present.
+ // Finds an element with key equivalent to `key` or returns `end()` if `key`
+ // is not present.
template <typename K>
iterator find(const K &key) {
return internal_end(internal_find(key));
@@ -1346,15 +1346,15 @@ class btree {
// Clear the btree, deleting all of the values it contains.
void clear();
- // Swaps the contents of `this` and `other`.
- void swap(btree &other);
+ // Swaps the contents of `this` and `other`.
+ void swap(btree &other);
const key_compare &key_comp() const noexcept {
return root_.template get<0>();
}
- template <typename K1, typename K2>
- bool compare_keys(const K1 &a, const K2 &b) const {
- return compare_internal::compare_result_as_less_than(key_comp()(a, b));
+ template <typename K1, typename K2>
+ bool compare_keys(const K1 &a, const K2 &b) const {
+ return compare_internal::compare_result_as_less_than(key_comp()(a, b));
}
value_compare value_comp() const {
@@ -1407,14 +1407,14 @@ class btree {
}
}
- // The average number of bytes used per value stored in the btree assuming
- // random insertion order.
+ // The average number of bytes used per value stored in the btree assuming
+ // random insertion order.
static double average_bytes_per_value() {
- // The expected number of values per node with random insertion order is the
- // average of the maximum and minimum numbers of values per node.
- const double expected_values_per_node =
- (kNodeSlots + kMinNodeValues) / 2.0;
- return node_type::LeafSize() / expected_values_per_node;
+ // The expected number of values per node with random insertion order is the
+ // average of the maximum and minimum numbers of values per node.
+ const double expected_values_per_node =
+ (kNodeSlots + kMinNodeValues) / 2.0;
+ return node_type::LeafSize() / expected_values_per_node;
}
// The fullness of the btree. Computed as the number of elements in the btree
@@ -1424,7 +1424,7 @@ class btree {
// Returns 0 for empty trees.
double fullness() const {
if (empty()) return 0.0;
- return static_cast<double>(size()) / (nodes() * kNodeSlots);
+ return static_cast<double>(size()) / (nodes() * kNodeSlots);
}
// The overhead of the btree structure in bytes per node. Computed as the
// total number of bytes used by the btree minus the number of bytes used for
@@ -1468,19 +1468,19 @@ class btree {
// Node creation/deletion routines.
node_type *new_internal_node(node_type *parent) {
- node_type *n = allocate(node_type::InternalSize());
- n->init_internal(parent);
- return n;
+ node_type *n = allocate(node_type::InternalSize());
+ n->init_internal(parent);
+ return n;
}
node_type *new_leaf_node(node_type *parent) {
- node_type *n = allocate(node_type::LeafSize());
- n->init_leaf(parent, kNodeSlots);
- return n;
+ node_type *n = allocate(node_type::LeafSize());
+ n->init_leaf(parent, kNodeSlots);
+ return n;
}
node_type *new_leaf_root_node(const int max_count) {
- node_type *n = allocate(node_type::LeafSize(max_count));
- n->init_leaf(/*parent=*/n, max_count);
- return n;
+ node_type *n = allocate(node_type::LeafSize(max_count));
+ n->init_leaf(/*parent=*/n, max_count);
+ return n;
}
// Deletion helper routines.
@@ -1523,19 +1523,19 @@ class btree {
static IterType internal_last(IterType iter);
// Returns an iterator pointing to the leaf position at which key would
- // reside in the tree, unless there is an exact match - in which case, the
- // result may not be on a leaf. When there's a three-way comparator, we can
- // return whether there was an exact match. This allows the caller to avoid a
- // subsequent comparison to determine if an exact match was made, which is
- // important for keys with expensive comparison, such as strings.
+ // reside in the tree, unless there is an exact match - in which case, the
+ // result may not be on a leaf. When there's a three-way comparator, we can
+ // return whether there was an exact match. This allows the caller to avoid a
+ // subsequent comparison to determine if an exact match was made, which is
+ // important for keys with expensive comparison, such as strings.
template <typename K>
SearchResult<iterator, is_key_compare_to::value> internal_locate(
const K &key) const;
// Internal routine which implements lower_bound().
template <typename K>
- SearchResult<iterator, is_key_compare_to::value> internal_lower_bound(
- const K &key) const;
+ SearchResult<iterator, is_key_compare_to::value> internal_lower_bound(
+ const K &key) const;
// Internal routine which implements upper_bound().
template <typename K>
@@ -1590,8 +1590,8 @@ inline void btree_node<P>::emplace_value(const size_type i,
// Shift old values to create space for new value and then construct it in
// place.
if (i < finish()) {
- transfer_n_backward(finish() - i, /*dest_i=*/i + 1, /*src_i=*/i, this,
- alloc);
+ transfer_n_backward(finish() - i, /*dest_i=*/i + 1, /*src_i=*/i, this,
+ alloc);
}
value_init(i, alloc, std::forward<Args>(args)...);
set_finish(finish() + 1);
@@ -1605,27 +1605,27 @@ inline void btree_node<P>::emplace_value(const size_type i,
}
template <typename P>
-inline void btree_node<P>::remove_values(const field_type i,
- const field_type to_erase,
- allocator_type *alloc) {
- // Transfer values after the removed range into their new places.
- value_destroy_n(i, to_erase, alloc);
- const field_type orig_finish = finish();
- const field_type src_i = i + to_erase;
- transfer_n(orig_finish - src_i, i, src_i, this, alloc);
-
- if (!leaf()) {
- // Delete all children between begin and end.
- for (int j = 0; j < to_erase; ++j) {
- clear_and_delete(child(i + j + 1), alloc);
- }
- // Rotate children after end into new positions.
- for (int j = i + to_erase + 1; j <= orig_finish; ++j) {
- set_child(j - to_erase, child(j));
- clear_child(j);
+inline void btree_node<P>::remove_values(const field_type i,
+ const field_type to_erase,
+ allocator_type *alloc) {
+ // Transfer values after the removed range into their new places.
+ value_destroy_n(i, to_erase, alloc);
+ const field_type orig_finish = finish();
+ const field_type src_i = i + to_erase;
+ transfer_n(orig_finish - src_i, i, src_i, this, alloc);
+
+ if (!leaf()) {
+ // Delete all children between begin and end.
+ for (int j = 0; j < to_erase; ++j) {
+ clear_and_delete(child(i + j + 1), alloc);
}
+ // Rotate children after end into new positions.
+ for (int j = i + to_erase + 1; j <= orig_finish; ++j) {
+ set_child(j - to_erase, child(j));
+ clear_child(j);
+ }
}
- set_finish(orig_finish - to_erase);
+ set_finish(orig_finish - to_erase);
}
template <typename P>
@@ -1639,17 +1639,17 @@ void btree_node<P>::rebalance_right_to_left(const int to_move,
assert(to_move <= right->count());
// 1) Move the delimiting value in the parent to the left node.
- transfer(finish(), position(), parent(), alloc);
+ transfer(finish(), position(), parent(), alloc);
// 2) Move the (to_move - 1) values from the right node to the left node.
- transfer_n(to_move - 1, finish() + 1, right->start(), right, alloc);
+ transfer_n(to_move - 1, finish() + 1, right->start(), right, alloc);
// 3) Move the new delimiting value to the parent from the right node.
- parent()->transfer(position(), right->start() + to_move - 1, right, alloc);
+ parent()->transfer(position(), right->start() + to_move - 1, right, alloc);
- // 4) Shift the values in the right node to their correct positions.
- right->transfer_n(right->count() - to_move, right->start(),
- right->start() + to_move, right, alloc);
+ // 4) Shift the values in the right node to their correct positions.
+ right->transfer_n(right->count() - to_move, right->start(),
+ right->start() + to_move, right, alloc);
if (!leaf()) {
// Move the child pointers from the right to the left node.
@@ -1684,19 +1684,19 @@ void btree_node<P>::rebalance_left_to_right(const int to_move,
// Lastly, a new delimiting value is moved from the left node into the
// parent, and the remaining empty left node entries are destroyed.
- // 1) Shift existing values in the right node to their correct positions.
- right->transfer_n_backward(right->count(), right->start() + to_move,
- right->start(), right, alloc);
+ // 1) Shift existing values in the right node to their correct positions.
+ right->transfer_n_backward(right->count(), right->start() + to_move,
+ right->start(), right, alloc);
- // 2) Move the delimiting value in the parent to the right node.
- right->transfer(right->start() + to_move - 1, position(), parent(), alloc);
+ // 2) Move the delimiting value in the parent to the right node.
+ right->transfer(right->start() + to_move - 1, position(), parent(), alloc);
- // 3) Move the (to_move - 1) values from the left node to the right node.
- right->transfer_n(to_move - 1, right->start(), finish() - (to_move - 1), this,
- alloc);
+ // 3) Move the (to_move - 1) values from the left node to the right node.
+ right->transfer_n(to_move - 1, right->start(), finish() - (to_move - 1), this,
+ alloc);
// 4) Move the new delimiting value to the parent from the left node.
- parent()->transfer(position(), finish() - to_move, this, alloc);
+ parent()->transfer(position(), finish() - to_move, this, alloc);
if (!leaf()) {
// Move the child pointers from the left to the right node.
@@ -1719,7 +1719,7 @@ template <typename P>
void btree_node<P>::split(const int insert_position, btree_node *dest,
allocator_type *alloc) {
assert(dest->count() == 0);
- assert(max_count() == kNodeSlots);
+ assert(max_count() == kNodeSlots);
// We bias the split based on the position being inserted. If we're
// inserting at the beginning of the left node then bias the split to put
@@ -1727,7 +1727,7 @@ void btree_node<P>::split(const int insert_position, btree_node *dest,
// right node then bias the split to put more values on the left node.
if (insert_position == start()) {
dest->set_finish(dest->start() + finish() - 1);
- } else if (insert_position == kNodeSlots) {
+ } else if (insert_position == kNodeSlots) {
dest->set_finish(dest->start());
} else {
dest->set_finish(dest->start() + count() / 2);
@@ -1736,7 +1736,7 @@ void btree_node<P>::split(const int insert_position, btree_node *dest,
assert(count() >= 1);
// Move values from the left sibling to the right sibling.
- dest->transfer_n(dest->count(), dest->start(), finish(), this, alloc);
+ dest->transfer_n(dest->count(), dest->start(), finish(), this, alloc);
// The split key is the largest value in the left sibling.
--mutable_finish();
@@ -1763,7 +1763,7 @@ void btree_node<P>::merge(btree_node *src, allocator_type *alloc) {
value_init(finish(), alloc, parent()->slot(position()));
// Move the values from the right to the left node.
- transfer_n(src->count(), finish() + 1, src->start(), src, alloc);
+ transfer_n(src->count(), finish() + 1, src->start(), src, alloc);
if (!leaf()) {
// Move the child pointers from the right to the left node.
@@ -1777,58 +1777,58 @@ void btree_node<P>::merge(btree_node *src, allocator_type *alloc) {
set_finish(start() + 1 + count() + src->count());
src->set_finish(src->start());
- // Remove the value on the parent node and delete the src node.
- parent()->remove_values(position(), /*to_erase=*/1, alloc);
+ // Remove the value on the parent node and delete the src node.
+ parent()->remove_values(position(), /*to_erase=*/1, alloc);
}
template <typename P>
-void btree_node<P>::clear_and_delete(btree_node *node, allocator_type *alloc) {
- if (node->leaf()) {
- node->value_destroy_n(node->start(), node->count(), alloc);
- deallocate(LeafSize(node->max_count()), node, alloc);
- return;
- }
- if (node->count() == 0) {
- deallocate(InternalSize(), node, alloc);
- return;
- }
-
- // The parent of the root of the subtree we are deleting.
- btree_node *delete_root_parent = node->parent();
-
- // Navigate to the leftmost leaf under node, and then delete upwards.
- while (!node->leaf()) node = node->start_child();
- // Use `int` because `pos` needs to be able to hold `kNodeSlots+1`, which
- // isn't guaranteed to be a valid `field_type`.
- int pos = node->position();
- btree_node *parent = node->parent();
- for (;;) {
- // In each iteration of the next loop, we delete one leaf node and go right.
- assert(pos <= parent->finish());
- do {
- node = parent->child(pos);
- if (!node->leaf()) {
- // Navigate to the leftmost leaf under node.
- while (!node->leaf()) node = node->start_child();
- pos = node->position();
- parent = node->parent();
- }
- node->value_destroy_n(node->start(), node->count(), alloc);
- deallocate(LeafSize(node->max_count()), node, alloc);
- ++pos;
- } while (pos <= parent->finish());
-
- // Once we've deleted all children of parent, delete parent and go up/right.
- assert(pos > parent->finish());
- do {
- node = parent;
- pos = node->position();
- parent = node->parent();
- node->value_destroy_n(node->start(), node->count(), alloc);
- deallocate(InternalSize(), node, alloc);
- if (parent == delete_root_parent) return;
- ++pos;
- } while (pos > parent->finish());
+void btree_node<P>::clear_and_delete(btree_node *node, allocator_type *alloc) {
+ if (node->leaf()) {
+ node->value_destroy_n(node->start(), node->count(), alloc);
+ deallocate(LeafSize(node->max_count()), node, alloc);
+ return;
+ }
+ if (node->count() == 0) {
+ deallocate(InternalSize(), node, alloc);
+ return;
+ }
+
+ // The parent of the root of the subtree we are deleting.
+ btree_node *delete_root_parent = node->parent();
+
+ // Navigate to the leftmost leaf under node, and then delete upwards.
+ while (!node->leaf()) node = node->start_child();
+ // Use `int` because `pos` needs to be able to hold `kNodeSlots+1`, which
+ // isn't guaranteed to be a valid `field_type`.
+ int pos = node->position();
+ btree_node *parent = node->parent();
+ for (;;) {
+ // In each iteration of the next loop, we delete one leaf node and go right.
+ assert(pos <= parent->finish());
+ do {
+ node = parent->child(pos);
+ if (!node->leaf()) {
+ // Navigate to the leftmost leaf under node.
+ while (!node->leaf()) node = node->start_child();
+ pos = node->position();
+ parent = node->parent();
+ }
+ node->value_destroy_n(node->start(), node->count(), alloc);
+ deallocate(LeafSize(node->max_count()), node, alloc);
+ ++pos;
+ } while (pos <= parent->finish());
+
+ // Once we've deleted all children of parent, delete parent and go up/right.
+ assert(pos > parent->finish());
+ do {
+ node = parent;
+ pos = node->position();
+ parent = node->parent();
+ node->value_destroy_n(node->start(), node->count(), alloc);
+ deallocate(InternalSize(), node, alloc);
+ if (parent == delete_root_parent) return;
+ ++pos;
+ } while (pos > parent->finish());
}
}
@@ -1844,7 +1844,7 @@ void btree_iterator<N, R, P>::increment_slow() {
position = node->position();
node = node->parent();
}
- // TODO(ezb): assert we aren't incrementing end() instead of handling.
+ // TODO(ezb): assert we aren't incrementing end() instead of handling.
if (position == node->finish()) {
*this = save;
}
@@ -1868,7 +1868,7 @@ void btree_iterator<N, R, P>::decrement_slow() {
position = node->position() - 1;
node = node->parent();
}
- // TODO(ezb): assert we aren't decrementing begin() instead of handling.
+ // TODO(ezb): assert we aren't decrementing begin() instead of handling.
if (position < node->start()) {
*this = save;
}
@@ -1886,7 +1886,7 @@ void btree_iterator<N, R, P>::decrement_slow() {
// btree methods
template <typename P>
template <typename Btree>
-void btree<P>::copy_or_move_values_in_order(Btree &other) {
+void btree<P>::copy_or_move_values_in_order(Btree &other) {
static_assert(std::is_same<btree, Btree>::value ||
std::is_same<const btree, Btree>::value,
"Btree type must be same or const.");
@@ -1894,11 +1894,11 @@ void btree<P>::copy_or_move_values_in_order(Btree &other) {
// We can avoid key comparisons because we know the order of the
// values is the same order we'll store them in.
- auto iter = other.begin();
- if (iter == other.end()) return;
+ auto iter = other.begin();
+ if (iter == other.end()) return;
insert_multi(maybe_move_from_iterator(iter));
++iter;
- for (; iter != other.end(); ++iter) {
+ for (; iter != other.end(); ++iter) {
// If the btree is not empty, we can just insert the new value at the end
// of the tree.
internal_emplace(end(), maybe_move_from_iterator(iter));
@@ -1917,7 +1917,7 @@ constexpr bool btree<P>::static_assert_validation() {
// Note: We assert that kTargetValues, which is computed from
// Params::kTargetNodeSize, must fit the node_type::field_type.
static_assert(
- kNodeSlots < (1 << (8 * sizeof(typename node_type::field_type))),
+ kNodeSlots < (1 << (8 * sizeof(typename node_type::field_type))),
"target node size too large");
// Verify that key_compare returns an y_absl::{weak,strong}_ordering or bool.
@@ -1937,57 +1937,57 @@ constexpr bool btree<P>::static_assert_validation() {
}
template <typename P>
-template <typename K>
-auto btree<P>::lower_bound_equal(const K &key) const
- -> std::pair<iterator, bool> {
- const SearchResult<iterator, is_key_compare_to::value> res =
- internal_lower_bound(key);
- const iterator lower = iterator(internal_end(res.value));
- const bool equal = res.HasMatch()
- ? res.IsEq()
- : lower != end() && !compare_keys(key, lower.key());
- return {lower, equal};
-}
+template <typename K>
+auto btree<P>::lower_bound_equal(const K &key) const
+ -> std::pair<iterator, bool> {
+ const SearchResult<iterator, is_key_compare_to::value> res =
+ internal_lower_bound(key);
+ const iterator lower = iterator(internal_end(res.value));
+ const bool equal = res.HasMatch()
+ ? res.IsEq()
+ : lower != end() && !compare_keys(key, lower.key());
+ return {lower, equal};
+}
template <typename P>
-template <typename K>
-auto btree<P>::equal_range(const K &key) -> std::pair<iterator, iterator> {
- const std::pair<iterator, bool> lower_and_equal = lower_bound_equal(key);
- const iterator lower = lower_and_equal.first;
- if (!lower_and_equal.second) {
- return {lower, lower};
- }
-
- const iterator next = std::next(lower);
- if (!params_type::template can_have_multiple_equivalent_keys<K>()) {
- // The next iterator after lower must point to a key greater than `key`.
- // Note: if this assert fails, then it may indicate that the comparator does
- // not meet the equivalence requirements for Compare
- // (see https://en.cppreference.com/w/cpp/named_req/Compare).
- assert(next == end() || compare_keys(key, next.key()));
- return {lower, next};
- }
- // Try once more to avoid the call to upper_bound() if there's only one
- // equivalent key. This should prevent all calls to upper_bound() in cases of
- // unique-containers with heterogeneous comparators in which all comparison
- // operators have the same equivalence classes.
- if (next == end() || compare_keys(key, next.key())) return {lower, next};
-
- // In this case, we need to call upper_bound() to avoid worst case O(N)
- // behavior if we were to iterate over equal keys.
- return {lower, upper_bound(key)};
+template <typename K>
+auto btree<P>::equal_range(const K &key) -> std::pair<iterator, iterator> {
+ const std::pair<iterator, bool> lower_and_equal = lower_bound_equal(key);
+ const iterator lower = lower_and_equal.first;
+ if (!lower_and_equal.second) {
+ return {lower, lower};
+ }
+
+ const iterator next = std::next(lower);
+ if (!params_type::template can_have_multiple_equivalent_keys<K>()) {
+ // The next iterator after lower must point to a key greater than `key`.
+ // Note: if this assert fails, then it may indicate that the comparator does
+ // not meet the equivalence requirements for Compare
+ // (see https://en.cppreference.com/w/cpp/named_req/Compare).
+ assert(next == end() || compare_keys(key, next.key()));
+ return {lower, next};
+ }
+ // Try once more to avoid the call to upper_bound() if there's only one
+ // equivalent key. This should prevent all calls to upper_bound() in cases of
+ // unique-containers with heterogeneous comparators in which all comparison
+ // operators have the same equivalence classes.
+ if (next == end() || compare_keys(key, next.key())) return {lower, next};
+
+ // In this case, we need to call upper_bound() to avoid worst case O(N)
+ // behavior if we were to iterate over equal keys.
+ return {lower, upper_bound(key)};
}
template <typename P>
-template <typename K, typename... Args>
-auto btree<P>::insert_unique(const K &key, Args &&... args)
+template <typename K, typename... Args>
+auto btree<P>::insert_unique(const K &key, Args &&... args)
-> std::pair<iterator, bool> {
if (empty()) {
mutable_root() = rightmost_ = new_leaf_root_node(1);
}
- SearchResult<iterator, is_key_compare_to::value> res = internal_locate(key);
- iterator iter = res.value;
+ SearchResult<iterator, is_key_compare_to::value> res = internal_locate(key);
+ iterator iter = res.value;
if (res.HasMatch()) {
if (res.IsEq()) {
@@ -2005,8 +2005,8 @@ auto btree<P>::insert_unique(const K &key, Args &&... args)
}
template <typename P>
-template <typename K, typename... Args>
-inline auto btree<P>::insert_hint_unique(iterator position, const K &key,
+template <typename K, typename... Args>
+inline auto btree<P>::insert_hint_unique(iterator position, const K &key,
Args &&... args)
-> std::pair<iterator, bool> {
if (!empty()) {
@@ -2030,23 +2030,23 @@ inline auto btree<P>::insert_hint_unique(iterator position, const K &key,
}
template <typename P>
-template <typename InputIterator, typename>
-void btree<P>::insert_iterator_unique(InputIterator b, InputIterator e, int) {
+template <typename InputIterator, typename>
+void btree<P>::insert_iterator_unique(InputIterator b, InputIterator e, int) {
for (; b != e; ++b) {
insert_hint_unique(end(), params_type::key(*b), *b);
}
}
template <typename P>
-template <typename InputIterator>
-void btree<P>::insert_iterator_unique(InputIterator b, InputIterator e, char) {
- for (; b != e; ++b) {
- init_type value(*b);
- insert_hint_unique(end(), params_type::key(value), std::move(value));
- }
-}
-
-template <typename P>
+template <typename InputIterator>
+void btree<P>::insert_iterator_unique(InputIterator b, InputIterator e, char) {
+ for (; b != e; ++b) {
+ init_type value(*b);
+ insert_hint_unique(end(), params_type::key(value), std::move(value));
+ }
+}
+
+template <typename P>
template <typename ValueType>
auto btree<P>::insert_multi(const key_type &key, ValueType &&v) -> iterator {
if (empty()) {
@@ -2091,47 +2091,47 @@ void btree<P>::insert_iterator_multi(InputIterator b, InputIterator e) {
}
template <typename P>
-auto btree<P>::operator=(const btree &other) -> btree & {
- if (this != &other) {
+auto btree<P>::operator=(const btree &other) -> btree & {
+ if (this != &other) {
clear();
- *mutable_key_comp() = other.key_comp();
+ *mutable_key_comp() = other.key_comp();
if (y_absl::allocator_traits<
allocator_type>::propagate_on_container_copy_assignment::value) {
- *mutable_allocator() = other.allocator();
+ *mutable_allocator() = other.allocator();
}
- copy_or_move_values_in_order(other);
+ copy_or_move_values_in_order(other);
}
return *this;
}
template <typename P>
-auto btree<P>::operator=(btree &&other) noexcept -> btree & {
- if (this != &other) {
+auto btree<P>::operator=(btree &&other) noexcept -> btree & {
+ if (this != &other) {
clear();
using std::swap;
if (y_absl::allocator_traits<
allocator_type>::propagate_on_container_copy_assignment::value) {
// Note: `root_` also contains the allocator and the key comparator.
- swap(root_, other.root_);
- swap(rightmost_, other.rightmost_);
- swap(size_, other.size_);
+ swap(root_, other.root_);
+ swap(rightmost_, other.rightmost_);
+ swap(size_, other.size_);
} else {
- if (allocator() == other.allocator()) {
- swap(mutable_root(), other.mutable_root());
- swap(*mutable_key_comp(), *other.mutable_key_comp());
- swap(rightmost_, other.rightmost_);
- swap(size_, other.size_);
+ if (allocator() == other.allocator()) {
+ swap(mutable_root(), other.mutable_root());
+ swap(*mutable_key_comp(), *other.mutable_key_comp());
+ swap(rightmost_, other.rightmost_);
+ swap(size_, other.size_);
} else {
// We aren't allowed to propagate the allocator and the allocator is
// different so we can't take over its memory. We must move each element
- // individually. We need both `other` and `this` to have `other`s key
- // comparator while moving the values so we can't swap the key
- // comparators.
- *mutable_key_comp() = other.key_comp();
- copy_or_move_values_in_order(other);
+ // individually. We need both `other` and `this` to have `other`s key
+ // comparator while moving the values so we can't swap the key
+ // comparators.
+ *mutable_key_comp() = other.key_comp();
+ copy_or_move_values_in_order(other);
}
}
}
@@ -2143,7 +2143,7 @@ auto btree<P>::erase(iterator iter) -> iterator {
bool internal_delete = false;
if (!iter.node->leaf()) {
// Deletion of a value on an internal node. First, move the largest value
- // from our left child here, then delete that position (in remove_values()
+ // from our left child here, then delete that position (in remove_values()
// below). We can get to the largest value from our left child by
// decrementing iter.
iterator internal_iter(iter);
@@ -2155,7 +2155,7 @@ auto btree<P>::erase(iterator iter) -> iterator {
}
// Delete the key from the leaf.
- iter.node->remove_values(iter.position, /*to_erase=*/1, mutable_allocator());
+ iter.node->remove_values(iter.position, /*to_erase=*/1, mutable_allocator());
--size_;
// We want to return the next value after the one we just erased. If we
@@ -2230,9 +2230,9 @@ auto btree<P>::erase_range(iterator begin, iterator end)
}
if (begin.node == end.node) {
- assert(end.position > begin.position);
- begin.node->remove_values(begin.position, end.position - begin.position,
- mutable_allocator());
+ assert(end.position > begin.position);
+ begin.node->remove_values(begin.position, end.position - begin.position,
+ mutable_allocator());
size_ -= count;
return {count, rebalance_after_delete(begin)};
}
@@ -2242,11 +2242,11 @@ auto btree<P>::erase_range(iterator begin, iterator end)
if (begin.node->leaf()) {
const size_type remaining_to_erase = size_ - target_size;
const size_type remaining_in_node = begin.node->finish() - begin.position;
- const size_type to_erase =
- (std::min)(remaining_to_erase, remaining_in_node);
- begin.node->remove_values(begin.position, to_erase, mutable_allocator());
- size_ -= to_erase;
- begin = rebalance_after_delete(begin);
+ const size_type to_erase =
+ (std::min)(remaining_to_erase, remaining_in_node);
+ begin.node->remove_values(begin.position, to_erase, mutable_allocator());
+ size_ -= to_erase;
+ begin = rebalance_after_delete(begin);
} else {
begin = erase(begin);
}
@@ -2257,7 +2257,7 @@ auto btree<P>::erase_range(iterator begin, iterator end)
template <typename P>
void btree<P>::clear() {
if (!empty()) {
- node_type::clear_and_delete(root(), mutable_allocator());
+ node_type::clear_and_delete(root(), mutable_allocator());
}
mutable_root() = EmptyNode();
rightmost_ = EmptyNode();
@@ -2265,20 +2265,20 @@ void btree<P>::clear() {
}
template <typename P>
-void btree<P>::swap(btree &other) {
+void btree<P>::swap(btree &other) {
using std::swap;
if (y_absl::allocator_traits<
allocator_type>::propagate_on_container_swap::value) {
// Note: `root_` also contains the allocator and the key comparator.
- swap(root_, other.root_);
+ swap(root_, other.root_);
} else {
// It's undefined behavior if the allocators are unequal here.
- assert(allocator() == other.allocator());
- swap(mutable_root(), other.mutable_root());
- swap(*mutable_key_comp(), *other.mutable_key_comp());
+ assert(allocator() == other.allocator());
+ swap(mutable_root(), other.mutable_root());
+ swap(*mutable_key_comp(), *other.mutable_key_comp());
}
- swap(rightmost_, other.rightmost_);
- swap(size_, other.size_);
+ swap(rightmost_, other.rightmost_);
+ swap(size_, other.size_);
}
template <typename P>
@@ -2298,7 +2298,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
node_type *&node = iter->node;
int &insert_position = iter->position;
assert(node->count() == node->max_count());
- assert(kNodeSlots == node->max_count());
+ assert(kNodeSlots == node->max_count());
// First try to make room on the node by rebalancing.
node_type *parent = node->parent();
@@ -2306,17 +2306,17 @@ void btree<P>::rebalance_or_split(iterator *iter) {
if (node->position() > parent->start()) {
// Try rebalancing with our left sibling.
node_type *left = parent->child(node->position() - 1);
- assert(left->max_count() == kNodeSlots);
- if (left->count() < kNodeSlots) {
+ assert(left->max_count() == kNodeSlots);
+ if (left->count() < kNodeSlots) {
// We bias rebalancing based on the position being inserted. If we're
// inserting at the end of the right node then we bias rebalancing to
// fill up the left node.
- int to_move = (kNodeSlots - left->count()) /
- (1 + (insert_position < static_cast<int>(kNodeSlots)));
+ int to_move = (kNodeSlots - left->count()) /
+ (1 + (insert_position < static_cast<int>(kNodeSlots)));
to_move = (std::max)(1, to_move);
if (insert_position - to_move >= node->start() ||
- left->count() + to_move < static_cast<int>(kNodeSlots)) {
+ left->count() + to_move < static_cast<int>(kNodeSlots)) {
left->rebalance_right_to_left(to_move, node, mutable_allocator());
assert(node->max_count() - node->count() == to_move);
@@ -2335,17 +2335,17 @@ void btree<P>::rebalance_or_split(iterator *iter) {
if (node->position() < parent->finish()) {
// Try rebalancing with our right sibling.
node_type *right = parent->child(node->position() + 1);
- assert(right->max_count() == kNodeSlots);
- if (right->count() < kNodeSlots) {
+ assert(right->max_count() == kNodeSlots);
+ if (right->count() < kNodeSlots) {
// We bias rebalancing based on the position being inserted. If we're
// inserting at the beginning of the left node then we bias rebalancing
// to fill up the right node.
- int to_move = (static_cast<int>(kNodeSlots) - right->count()) /
+ int to_move = (static_cast<int>(kNodeSlots) - right->count()) /
(1 + (insert_position > node->start()));
to_move = (std::max)(1, to_move);
if (insert_position <= node->finish() - to_move ||
- right->count() + to_move < static_cast<int>(kNodeSlots)) {
+ right->count() + to_move < static_cast<int>(kNodeSlots)) {
node->rebalance_left_to_right(to_move, right, mutable_allocator());
if (insert_position > node->finish()) {
@@ -2361,8 +2361,8 @@ void btree<P>::rebalance_or_split(iterator *iter) {
// Rebalancing failed, make sure there is room on the parent node for a new
// value.
- assert(parent->max_count() == kNodeSlots);
- if (parent->count() == kNodeSlots) {
+ assert(parent->max_count() == kNodeSlots);
+ if (parent->count() == kNodeSlots) {
iterator parent_iter(node->parent(), node->position());
rebalance_or_split(&parent_iter);
}
@@ -2398,7 +2398,7 @@ void btree<P>::rebalance_or_split(iterator *iter) {
template <typename P>
void btree<P>::merge_nodes(node_type *left, node_type *right) {
left->merge(right, mutable_allocator());
- if (rightmost_ == right) rightmost_ = left;
+ if (rightmost_ == right) rightmost_ = left;
}
template <typename P>
@@ -2407,8 +2407,8 @@ bool btree<P>::try_merge_or_rebalance(iterator *iter) {
if (iter->node->position() > parent->start()) {
// Try merging with our left sibling.
node_type *left = parent->child(iter->node->position() - 1);
- assert(left->max_count() == kNodeSlots);
- if (1U + left->count() + iter->node->count() <= kNodeSlots) {
+ assert(left->max_count() == kNodeSlots);
+ if (1U + left->count() + iter->node->count() <= kNodeSlots) {
iter->position += 1 + left->count();
merge_nodes(left, iter->node);
iter->node = left;
@@ -2418,8 +2418,8 @@ bool btree<P>::try_merge_or_rebalance(iterator *iter) {
if (iter->node->position() < parent->finish()) {
// Try merging with our right sibling.
node_type *right = parent->child(iter->node->position() + 1);
- assert(right->max_count() == kNodeSlots);
- if (1U + iter->node->count() + right->count() <= kNodeSlots) {
+ assert(right->max_count() == kNodeSlots);
+ if (1U + iter->node->count() + right->count() <= kNodeSlots) {
merge_nodes(iter->node, right);
return true;
}
@@ -2455,20 +2455,20 @@ bool btree<P>::try_merge_or_rebalance(iterator *iter) {
template <typename P>
void btree<P>::try_shrink() {
- node_type *orig_root = root();
- if (orig_root->count() > 0) {
+ node_type *orig_root = root();
+ if (orig_root->count() > 0) {
return;
}
// Deleted the last item on the root node, shrink the height of the tree.
- if (orig_root->leaf()) {
+ if (orig_root->leaf()) {
assert(size() == 0);
- mutable_root() = rightmost_ = EmptyNode();
+ mutable_root() = rightmost_ = EmptyNode();
} else {
- node_type *child = orig_root->start_child();
+ node_type *child = orig_root->start_child();
child->make_root();
mutable_root() = child;
}
- node_type::clear_and_delete(orig_root, mutable_allocator());
+ node_type::clear_and_delete(orig_root, mutable_allocator());
}
template <typename P>
@@ -2496,30 +2496,30 @@ inline auto btree<P>::internal_emplace(iterator iter, Args &&... args)
--iter;
++iter.position;
}
- const field_type max_count = iter.node->max_count();
- allocator_type *alloc = mutable_allocator();
+ const field_type max_count = iter.node->max_count();
+ allocator_type *alloc = mutable_allocator();
if (iter.node->count() == max_count) {
// Make room in the leaf for the new item.
- if (max_count < kNodeSlots) {
+ if (max_count < kNodeSlots) {
// Insertion into the root where the root is smaller than the full node
// size. Simply grow the size of the root node.
assert(iter.node == root());
iter.node =
- new_leaf_root_node((std::min<int>)(kNodeSlots, 2 * max_count));
- // Transfer the values from the old root to the new root.
- node_type *old_root = root();
- node_type *new_root = iter.node;
- new_root->transfer_n(old_root->count(), new_root->start(),
- old_root->start(), old_root, alloc);
- new_root->set_finish(old_root->finish());
- old_root->set_finish(old_root->start());
- node_type::clear_and_delete(old_root, alloc);
- mutable_root() = rightmost_ = new_root;
+ new_leaf_root_node((std::min<int>)(kNodeSlots, 2 * max_count));
+ // Transfer the values from the old root to the new root.
+ node_type *old_root = root();
+ node_type *new_root = iter.node;
+ new_root->transfer_n(old_root->count(), new_root->start(),
+ old_root->start(), old_root, alloc);
+ new_root->set_finish(old_root->finish());
+ old_root->set_finish(old_root->start());
+ node_type::clear_and_delete(old_root, alloc);
+ mutable_root() = rightmost_ = new_root;
} else {
rebalance_or_split(&iter);
}
}
- iter.node->emplace_value(iter.position, alloc, std::forward<Args>(args)...);
+ iter.node->emplace_value(iter.position, alloc, std::forward<Args>(args)...);
++size_;
return iter;
}
@@ -2530,49 +2530,49 @@ inline auto btree<P>::internal_locate(const K &key) const
-> SearchResult<iterator, is_key_compare_to::value> {
iterator iter(const_cast<node_type *>(root()));
for (;;) {
- SearchResult<int, is_key_compare_to::value> res =
- iter.node->lower_bound(key, key_comp());
+ SearchResult<int, is_key_compare_to::value> res =
+ iter.node->lower_bound(key, key_comp());
iter.position = res.value;
- if (res.IsEq()) {
+ if (res.IsEq()) {
return {iter, MatchKind::kEq};
}
- // Note: in the non-key-compare-to case, we don't need to walk all the way
- // down the tree if the keys are equal, but determining equality would
- // require doing an extra comparison on each node on the way down, and we
- // will need to go all the way to the leaf node in the expected case.
+ // Note: in the non-key-compare-to case, we don't need to walk all the way
+ // down the tree if the keys are equal, but determining equality would
+ // require doing an extra comparison on each node on the way down, and we
+ // will need to go all the way to the leaf node in the expected case.
if (iter.node->leaf()) {
break;
}
iter.node = iter.node->child(iter.position);
}
- // Note: in the non-key-compare-to case, the key may actually be equivalent
- // here (and the MatchKind::kNe is ignored).
+ // Note: in the non-key-compare-to case, the key may actually be equivalent
+ // here (and the MatchKind::kNe is ignored).
return {iter, MatchKind::kNe};
}
template <typename P>
template <typename K>
-auto btree<P>::internal_lower_bound(const K &key) const
- -> SearchResult<iterator, is_key_compare_to::value> {
- if (!params_type::template can_have_multiple_equivalent_keys<K>()) {
- SearchResult<iterator, is_key_compare_to::value> ret = internal_locate(key);
- ret.value = internal_last(ret.value);
- return ret;
- }
+auto btree<P>::internal_lower_bound(const K &key) const
+ -> SearchResult<iterator, is_key_compare_to::value> {
+ if (!params_type::template can_have_multiple_equivalent_keys<K>()) {
+ SearchResult<iterator, is_key_compare_to::value> ret = internal_locate(key);
+ ret.value = internal_last(ret.value);
+ return ret;
+ }
iterator iter(const_cast<node_type *>(root()));
- SearchResult<int, is_key_compare_to::value> res;
- bool seen_eq = false;
+ SearchResult<int, is_key_compare_to::value> res;
+ bool seen_eq = false;
for (;;) {
- res = iter.node->lower_bound(key, key_comp());
- iter.position = res.value;
+ res = iter.node->lower_bound(key, key_comp());
+ iter.position = res.value;
if (iter.node->leaf()) {
break;
}
- seen_eq = seen_eq || res.IsEq();
+ seen_eq = seen_eq || res.IsEq();
iter.node = iter.node->child(iter.position);
}
- if (res.IsEq()) return {iter, MatchKind::kEq};
- return {internal_last(iter), seen_eq ? MatchKind::kEq : MatchKind::kNe};
+ if (res.IsEq()) return {iter, MatchKind::kEq};
+ return {internal_last(iter), seen_eq ? MatchKind::kEq : MatchKind::kNe};
}
template <typename P>
@@ -2592,7 +2592,7 @@ auto btree<P>::internal_upper_bound(const K &key) const -> iterator {
template <typename P>
template <typename K>
auto btree<P>::internal_find(const K &key) const -> iterator {
- SearchResult<iterator, is_key_compare_to::value> res = internal_locate(key);
+ SearchResult<iterator, is_key_compare_to::value> res = internal_locate(key);
if (res.HasMatch()) {
if (res.IsEq()) {
return res.value;
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h
index d23feff31b..d67a7fe890 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h
@@ -24,7 +24,7 @@
#include "y_absl/base/internal/throw_delegate.h"
#include "y_absl/container/internal/btree.h" // IWYU pragma: export
#include "y_absl/container/internal/common.h"
-#include "y_absl/memory/memory.h"
+#include "y_absl/memory/memory.h"
#include "y_absl/meta/type_traits.h"
namespace y_absl {
@@ -70,23 +70,23 @@ class btree_container {
explicit btree_container(const key_compare &comp,
const allocator_type &alloc = allocator_type())
: tree_(comp, alloc) {}
- explicit btree_container(const allocator_type &alloc)
- : tree_(key_compare(), alloc) {}
-
- btree_container(const btree_container &other)
- : btree_container(other, y_absl::allocator_traits<allocator_type>::
- select_on_container_copy_construction(
- other.get_allocator())) {}
- btree_container(const btree_container &other, const allocator_type &alloc)
- : tree_(other.tree_, alloc) {}
-
- btree_container(btree_container &&other) noexcept(
- std::is_nothrow_move_constructible<Tree>::value) = default;
- btree_container(btree_container &&other, const allocator_type &alloc)
- : tree_(std::move(other.tree_), alloc) {}
-
- btree_container &operator=(const btree_container &other) = default;
- btree_container &operator=(btree_container &&other) noexcept(
+ explicit btree_container(const allocator_type &alloc)
+ : tree_(key_compare(), alloc) {}
+
+ btree_container(const btree_container &other)
+ : btree_container(other, y_absl::allocator_traits<allocator_type>::
+ select_on_container_copy_construction(
+ other.get_allocator())) {}
+ btree_container(const btree_container &other, const allocator_type &alloc)
+ : tree_(other.tree_, alloc) {}
+
+ btree_container(btree_container &&other) noexcept(
+ std::is_nothrow_move_constructible<Tree>::value) = default;
+ btree_container(btree_container &&other, const allocator_type &alloc)
+ : tree_(std::move(other.tree_), alloc) {}
+
+ btree_container &operator=(const btree_container &other) = default;
+ btree_container &operator=(btree_container &&other) noexcept(
std::is_nothrow_move_assignable<Tree>::value) = default;
// Iterator routines.
@@ -105,11 +105,11 @@ class btree_container {
// Lookup routines.
template <typename K = key_type>
- size_type count(const key_arg<K> &key) const {
- auto equal_range = this->equal_range(key);
- return std::distance(equal_range.first, equal_range.second);
- }
- template <typename K = key_type>
+ size_type count(const key_arg<K> &key) const {
+ auto equal_range = this->equal_range(key);
+ return std::distance(equal_range.first, equal_range.second);
+ }
+ template <typename K = key_type>
iterator find(const key_arg<K> &key) {
return tree_.find(key);
}
@@ -158,11 +158,11 @@ class btree_container {
iterator erase(const_iterator first, const_iterator last) {
return tree_.erase_range(iterator(first), iterator(last)).second;
}
- template <typename K = key_type>
- size_type erase(const key_arg<K> &key) {
- auto equal_range = this->equal_range(key);
- return tree_.erase_range(equal_range.first, equal_range.second).first;
- }
+ template <typename K = key_type>
+ size_type erase(const key_arg<K> &key) {
+ auto equal_range = this->equal_range(key);
+ return tree_.erase_range(equal_range.first, equal_range.second).first;
+ }
// Extract routines.
node_type extract(iterator position) {
@@ -178,7 +178,7 @@ class btree_container {
// Utility routines.
ABSL_ATTRIBUTE_REINITIALIZES void clear() { tree_.clear(); }
- void swap(btree_container &other) { tree_.swap(other.tree_); }
+ void swap(btree_container &other) { tree_.swap(other.tree_); }
void verify() const { tree_.verify(); }
// Size routines.
@@ -259,7 +259,7 @@ class btree_set_container : public btree_container<Tree> {
using super_type::super_type;
btree_set_container() {}
- // Range constructors.
+ // Range constructors.
template <class InputIterator>
btree_set_container(InputIterator b, InputIterator e,
const key_compare &comp = key_compare(),
@@ -267,55 +267,55 @@ class btree_set_container : public btree_container<Tree> {
: super_type(comp, alloc) {
insert(b, e);
}
- template <class InputIterator>
- btree_set_container(InputIterator b, InputIterator e,
- const allocator_type &alloc)
- : btree_set_container(b, e, key_compare(), alloc) {}
+ template <class InputIterator>
+ btree_set_container(InputIterator b, InputIterator e,
+ const allocator_type &alloc)
+ : btree_set_container(b, e, key_compare(), alloc) {}
- // Initializer list constructors.
+ // Initializer list constructors.
btree_set_container(std::initializer_list<init_type> init,
const key_compare &comp = key_compare(),
const allocator_type &alloc = allocator_type())
: btree_set_container(init.begin(), init.end(), comp, alloc) {}
- btree_set_container(std::initializer_list<init_type> init,
- const allocator_type &alloc)
- : btree_set_container(init.begin(), init.end(), alloc) {}
+ btree_set_container(std::initializer_list<init_type> init,
+ const allocator_type &alloc)
+ : btree_set_container(init.begin(), init.end(), alloc) {}
// Insertion routines.
- std::pair<iterator, bool> insert(const value_type &v) {
- return this->tree_.insert_unique(params_type::key(v), v);
+ std::pair<iterator, bool> insert(const value_type &v) {
+ return this->tree_.insert_unique(params_type::key(v), v);
}
- std::pair<iterator, bool> insert(value_type &&v) {
- return this->tree_.insert_unique(params_type::key(v), std::move(v));
+ std::pair<iterator, bool> insert(value_type &&v) {
+ return this->tree_.insert_unique(params_type::key(v), std::move(v));
}
template <typename... Args>
std::pair<iterator, bool> emplace(Args &&... args) {
init_type v(std::forward<Args>(args)...);
return this->tree_.insert_unique(params_type::key(v), std::move(v));
}
- iterator insert(const_iterator hint, const value_type &v) {
+ iterator insert(const_iterator hint, const value_type &v) {
return this->tree_
- .insert_hint_unique(iterator(hint), params_type::key(v), v)
+ .insert_hint_unique(iterator(hint), params_type::key(v), v)
.first;
}
- iterator insert(const_iterator hint, value_type &&v) {
+ iterator insert(const_iterator hint, value_type &&v) {
return this->tree_
- .insert_hint_unique(iterator(hint), params_type::key(v), std::move(v))
+ .insert_hint_unique(iterator(hint), params_type::key(v), std::move(v))
.first;
}
template <typename... Args>
- iterator emplace_hint(const_iterator hint, Args &&... args) {
+ iterator emplace_hint(const_iterator hint, Args &&... args) {
init_type v(std::forward<Args>(args)...);
return this->tree_
- .insert_hint_unique(iterator(hint), params_type::key(v), std::move(v))
+ .insert_hint_unique(iterator(hint), params_type::key(v), std::move(v))
.first;
}
template <typename InputIterator>
void insert(InputIterator b, InputIterator e) {
- this->tree_.insert_iterator_unique(b, e, 0);
+ this->tree_.insert_iterator_unique(b, e, 0);
}
void insert(std::initializer_list<init_type> init) {
- this->tree_.insert_iterator_unique(init.begin(), init.end(), 0);
+ this->tree_.insert_iterator_unique(init.begin(), init.end(), 0);
}
insert_return_type insert(node_type &&node) {
if (!node) return {this->end(), false, node_type()};
@@ -341,10 +341,10 @@ class btree_set_container : public btree_container<Tree> {
// Node extraction routines.
template <typename K = key_type>
node_type extract(const key_arg<K> &key) {
- const std::pair<iterator, bool> lower_and_equal =
- this->tree_.lower_bound_equal(key);
- return lower_and_equal.second ? extract(lower_and_equal.first)
- : node_type();
+ const std::pair<iterator, bool> lower_and_equal =
+ this->tree_.lower_bound_equal(key);
+ return lower_and_equal.second ? extract(lower_and_equal.first)
+ : node_type();
}
using super_type::extract;
@@ -362,7 +362,7 @@ class btree_set_container : public btree_container<Tree> {
int> = 0>
void merge(btree_container<T> &src) { // NOLINT
for (auto src_it = src.begin(); src_it != src.end();) {
- if (insert(std::move(params_type::element(src_it.slot()))).second) {
+ if (insert(std::move(params_type::element(src_it.slot()))).second) {
src_it = src.erase(src_it);
} else {
++src_it;
@@ -389,7 +389,7 @@ template <typename Tree>
class btree_map_container : public btree_set_container<Tree> {
using super_type = btree_set_container<Tree>;
using params_type = typename Tree::params_type;
- friend class BtreeNodePeer;
+ friend class BtreeNodePeer;
private:
template <class K>
@@ -411,72 +411,72 @@ class btree_map_container : public btree_set_container<Tree> {
// Insertion routines.
// Note: the nullptr template arguments and extra `const M&` overloads allow
// for supporting bitfield arguments.
- template <typename K = key_type, class M>
- std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k,
- const M &obj) {
- return insert_or_assign_impl(k, obj);
+ template <typename K = key_type, class M>
+ std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k,
+ const M &obj) {
+ return insert_or_assign_impl(k, obj);
}
- template <typename K = key_type, class M, K * = nullptr>
- std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, const M &obj) {
- return insert_or_assign_impl(std::forward<K>(k), obj);
+ template <typename K = key_type, class M, K * = nullptr>
+ std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, const M &obj) {
+ return insert_or_assign_impl(std::forward<K>(k), obj);
}
- template <typename K = key_type, class M, M * = nullptr>
- std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k, M &&obj) {
- return insert_or_assign_impl(k, std::forward<M>(obj));
+ template <typename K = key_type, class M, M * = nullptr>
+ std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k, M &&obj) {
+ return insert_or_assign_impl(k, std::forward<M>(obj));
}
- template <typename K = key_type, class M, K * = nullptr, M * = nullptr>
- std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, M &&obj) {
- return insert_or_assign_impl(std::forward<K>(k), std::forward<M>(obj));
+ template <typename K = key_type, class M, K * = nullptr, M * = nullptr>
+ std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, M &&obj) {
+ return insert_or_assign_impl(std::forward<K>(k), std::forward<M>(obj));
}
- template <typename K = key_type, class M>
- iterator insert_or_assign(const_iterator hint, const key_arg<K> &k,
+ template <typename K = key_type, class M>
+ iterator insert_or_assign(const_iterator hint, const key_arg<K> &k,
const M &obj) {
- return insert_or_assign_hint_impl(hint, k, obj);
- }
- template <typename K = key_type, class M, K * = nullptr>
- iterator insert_or_assign(const_iterator hint, key_arg<K> &&k, const M &obj) {
- return insert_or_assign_hint_impl(hint, std::forward<K>(k), obj);
- }
- template <typename K = key_type, class M, M * = nullptr>
- iterator insert_or_assign(const_iterator hint, const key_arg<K> &k, M &&obj) {
- return insert_or_assign_hint_impl(hint, k, std::forward<M>(obj));
- }
- template <typename K = key_type, class M, K * = nullptr, M * = nullptr>
- iterator insert_or_assign(const_iterator hint, key_arg<K> &&k, M &&obj) {
- return insert_or_assign_hint_impl(hint, std::forward<K>(k),
- std::forward<M>(obj));
- }
-
- template <typename K = key_type, typename... Args,
- typename y_absl::enable_if_t<
- !std::is_convertible<K, const_iterator>::value, int> = 0>
- std::pair<iterator, bool> try_emplace(const key_arg<K> &k, Args &&... args) {
- return try_emplace_impl(k, std::forward<Args>(args)...);
- }
- template <typename K = key_type, typename... Args,
- typename y_absl::enable_if_t<
- !std::is_convertible<K, const_iterator>::value, int> = 0>
- std::pair<iterator, bool> try_emplace(key_arg<K> &&k, Args &&... args) {
- return try_emplace_impl(std::forward<K>(k), std::forward<Args>(args)...);
- }
- template <typename K = key_type, typename... Args>
- iterator try_emplace(const_iterator hint, const key_arg<K> &k,
+ return insert_or_assign_hint_impl(hint, k, obj);
+ }
+ template <typename K = key_type, class M, K * = nullptr>
+ iterator insert_or_assign(const_iterator hint, key_arg<K> &&k, const M &obj) {
+ return insert_or_assign_hint_impl(hint, std::forward<K>(k), obj);
+ }
+ template <typename K = key_type, class M, M * = nullptr>
+ iterator insert_or_assign(const_iterator hint, const key_arg<K> &k, M &&obj) {
+ return insert_or_assign_hint_impl(hint, k, std::forward<M>(obj));
+ }
+ template <typename K = key_type, class M, K * = nullptr, M * = nullptr>
+ iterator insert_or_assign(const_iterator hint, key_arg<K> &&k, M &&obj) {
+ return insert_or_assign_hint_impl(hint, std::forward<K>(k),
+ std::forward<M>(obj));
+ }
+
+ template <typename K = key_type, typename... Args,
+ typename y_absl::enable_if_t<
+ !std::is_convertible<K, const_iterator>::value, int> = 0>
+ std::pair<iterator, bool> try_emplace(const key_arg<K> &k, Args &&... args) {
+ return try_emplace_impl(k, std::forward<Args>(args)...);
+ }
+ template <typename K = key_type, typename... Args,
+ typename y_absl::enable_if_t<
+ !std::is_convertible<K, const_iterator>::value, int> = 0>
+ std::pair<iterator, bool> try_emplace(key_arg<K> &&k, Args &&... args) {
+ return try_emplace_impl(std::forward<K>(k), std::forward<Args>(args)...);
+ }
+ template <typename K = key_type, typename... Args>
+ iterator try_emplace(const_iterator hint, const key_arg<K> &k,
Args &&... args) {
- return try_emplace_hint_impl(hint, k, std::forward<Args>(args)...);
+ return try_emplace_hint_impl(hint, k, std::forward<Args>(args)...);
}
- template <typename K = key_type, typename... Args>
- iterator try_emplace(const_iterator hint, key_arg<K> &&k, Args &&... args) {
- return try_emplace_hint_impl(hint, std::forward<K>(k),
- std::forward<Args>(args)...);
+ template <typename K = key_type, typename... Args>
+ iterator try_emplace(const_iterator hint, key_arg<K> &&k, Args &&... args) {
+ return try_emplace_hint_impl(hint, std::forward<K>(k),
+ std::forward<Args>(args)...);
}
-
- template <typename K = key_type>
- mapped_type &operator[](const key_arg<K> &k) {
+
+ template <typename K = key_type>
+ mapped_type &operator[](const key_arg<K> &k) {
return try_emplace(k).first->second;
}
- template <typename K = key_type>
- mapped_type &operator[](key_arg<K> &&k) {
- return try_emplace(std::forward<K>(k)).first->second;
+ template <typename K = key_type>
+ mapped_type &operator[](key_arg<K> &&k) {
+ return try_emplace(std::forward<K>(k)).first->second;
}
template <typename K = key_type>
@@ -493,40 +493,40 @@ class btree_map_container : public btree_set_container<Tree> {
base_internal::ThrowStdOutOfRange("y_absl::btree_map::at");
return it->second;
}
-
- private:
- // Note: when we call `std::forward<M>(obj)` twice, it's safe because
- // insert_unique/insert_hint_unique are guaranteed to not consume `obj` when
- // `ret.second` is false.
- template <class K, class M>
- std::pair<iterator, bool> insert_or_assign_impl(K &&k, M &&obj) {
- const std::pair<iterator, bool> ret =
- this->tree_.insert_unique(k, std::forward<K>(k), std::forward<M>(obj));
- if (!ret.second) ret.first->second = std::forward<M>(obj);
- return ret;
- }
- template <class K, class M>
- iterator insert_or_assign_hint_impl(const_iterator hint, K &&k, M &&obj) {
- const std::pair<iterator, bool> ret = this->tree_.insert_hint_unique(
- iterator(hint), k, std::forward<K>(k), std::forward<M>(obj));
- if (!ret.second) ret.first->second = std::forward<M>(obj);
- return ret.first;
- }
-
- template <class K, class... Args>
- std::pair<iterator, bool> try_emplace_impl(K &&k, Args &&... args) {
- return this->tree_.insert_unique(
- k, std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)),
- std::forward_as_tuple(std::forward<Args>(args)...));
- }
- template <class K, class... Args>
- iterator try_emplace_hint_impl(const_iterator hint, K &&k, Args &&... args) {
- return this->tree_
- .insert_hint_unique(iterator(hint), k, std::piecewise_construct,
- std::forward_as_tuple(std::forward<K>(k)),
- std::forward_as_tuple(std::forward<Args>(args)...))
- .first;
- }
+
+ private:
+ // Note: when we call `std::forward<M>(obj)` twice, it's safe because
+ // insert_unique/insert_hint_unique are guaranteed to not consume `obj` when
+ // `ret.second` is false.
+ template <class K, class M>
+ std::pair<iterator, bool> insert_or_assign_impl(K &&k, M &&obj) {
+ const std::pair<iterator, bool> ret =
+ this->tree_.insert_unique(k, std::forward<K>(k), std::forward<M>(obj));
+ if (!ret.second) ret.first->second = std::forward<M>(obj);
+ return ret;
+ }
+ template <class K, class M>
+ iterator insert_or_assign_hint_impl(const_iterator hint, K &&k, M &&obj) {
+ const std::pair<iterator, bool> ret = this->tree_.insert_hint_unique(
+ iterator(hint), k, std::forward<K>(k), std::forward<M>(obj));
+ if (!ret.second) ret.first->second = std::forward<M>(obj);
+ return ret.first;
+ }
+
+ template <class K, class... Args>
+ std::pair<iterator, bool> try_emplace_impl(K &&k, Args &&... args) {
+ return this->tree_.insert_unique(
+ k, std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)),
+ std::forward_as_tuple(std::forward<Args>(args)...));
+ }
+ template <class K, class... Args>
+ iterator try_emplace_hint_impl(const_iterator hint, K &&k, Args &&... args) {
+ return this->tree_
+ .insert_hint_unique(iterator(hint), k, std::piecewise_construct,
+ std::forward_as_tuple(std::forward<K>(k)),
+ std::forward_as_tuple(std::forward<Args>(args)...))
+ .first;
+ }
};
// A common base class for btree_multiset and btree_multimap.
@@ -554,7 +554,7 @@ class btree_multiset_container : public btree_container<Tree> {
using super_type::super_type;
btree_multiset_container() {}
- // Range constructors.
+ // Range constructors.
template <class InputIterator>
btree_multiset_container(InputIterator b, InputIterator e,
const key_compare &comp = key_compare(),
@@ -562,30 +562,30 @@ class btree_multiset_container : public btree_container<Tree> {
: super_type(comp, alloc) {
insert(b, e);
}
- template <class InputIterator>
- btree_multiset_container(InputIterator b, InputIterator e,
- const allocator_type &alloc)
- : btree_multiset_container(b, e, key_compare(), alloc) {}
+ template <class InputIterator>
+ btree_multiset_container(InputIterator b, InputIterator e,
+ const allocator_type &alloc)
+ : btree_multiset_container(b, e, key_compare(), alloc) {}
- // Initializer list constructors.
+ // Initializer list constructors.
btree_multiset_container(std::initializer_list<init_type> init,
const key_compare &comp = key_compare(),
const allocator_type &alloc = allocator_type())
: btree_multiset_container(init.begin(), init.end(), comp, alloc) {}
- btree_multiset_container(std::initializer_list<init_type> init,
- const allocator_type &alloc)
- : btree_multiset_container(init.begin(), init.end(), alloc) {}
+ btree_multiset_container(std::initializer_list<init_type> init,
+ const allocator_type &alloc)
+ : btree_multiset_container(init.begin(), init.end(), alloc) {}
// Insertion routines.
- iterator insert(const value_type &v) { return this->tree_.insert_multi(v); }
- iterator insert(value_type &&v) {
- return this->tree_.insert_multi(std::move(v));
+ iterator insert(const value_type &v) { return this->tree_.insert_multi(v); }
+ iterator insert(value_type &&v) {
+ return this->tree_.insert_multi(std::move(v));
}
- iterator insert(const_iterator hint, const value_type &v) {
- return this->tree_.insert_hint_multi(iterator(hint), v);
+ iterator insert(const_iterator hint, const value_type &v) {
+ return this->tree_.insert_hint_multi(iterator(hint), v);
}
- iterator insert(const_iterator hint, value_type &&v) {
- return this->tree_.insert_hint_multi(iterator(hint), std::move(v));
+ iterator insert(const_iterator hint, value_type &&v) {
+ return this->tree_.insert_hint_multi(iterator(hint), std::move(v));
}
template <typename InputIterator>
void insert(InputIterator b, InputIterator e) {
@@ -599,9 +599,9 @@ class btree_multiset_container : public btree_container<Tree> {
return this->tree_.insert_multi(init_type(std::forward<Args>(args)...));
}
template <typename... Args>
- iterator emplace_hint(const_iterator hint, Args &&... args) {
+ iterator emplace_hint(const_iterator hint, Args &&... args) {
return this->tree_.insert_hint_multi(
- iterator(hint), init_type(std::forward<Args>(args)...));
+ iterator(hint), init_type(std::forward<Args>(args)...));
}
iterator insert(node_type &&node) {
if (!node) return this->end();
@@ -623,10 +623,10 @@ class btree_multiset_container : public btree_container<Tree> {
// Node extraction routines.
template <typename K = key_type>
node_type extract(const key_arg<K> &key) {
- const std::pair<iterator, bool> lower_and_equal =
- this->tree_.lower_bound_equal(key);
- return lower_and_equal.second ? extract(lower_and_equal.first)
- : node_type();
+ const std::pair<iterator, bool> lower_and_equal =
+ this->tree_.lower_bound_equal(key);
+ return lower_and_equal.second ? extract(lower_and_equal.first)
+ : node_type();
}
using super_type::extract;
@@ -642,9 +642,9 @@ class btree_multiset_container : public btree_container<Tree> {
typename T::params_type::is_map_container>>::value,
int> = 0>
void merge(btree_container<T> &src) { // NOLINT
- for (auto src_it = src.begin(), end = src.end(); src_it != end; ++src_it) {
- insert(std::move(params_type::element(src_it.slot())));
- }
+ for (auto src_it = src.begin(), end = src.end(); src_it != end; ++src_it) {
+ insert(std::move(params_type::element(src_it.slot())));
+ }
src.clear();
}
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h
index ec84f975e5..1e02f0ca34 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h
@@ -138,7 +138,7 @@ class node_handle<Policy, PolicyTraits, Alloc,
y_absl::void_t<typename Policy::mapped_type>>
: public node_handle_base<PolicyTraits, Alloc> {
using Base = node_handle_base<PolicyTraits, Alloc>;
- using slot_type = typename PolicyTraits::slot_type;
+ using slot_type = typename PolicyTraits::slot_type;
public:
using key_type = typename Policy::key_type;
@@ -146,11 +146,11 @@ class node_handle<Policy, PolicyTraits, Alloc,
constexpr node_handle() {}
- // When C++17 is available, we can use std::launder to provide mutable
- // access to the key. Otherwise, we provide const access.
- auto key() const
- -> decltype(PolicyTraits::mutable_key(std::declval<slot_type*>())) {
- return PolicyTraits::mutable_key(this->slot());
+ // When C++17 is available, we can use std::launder to provide mutable
+ // access to the key. Otherwise, we provide const access.
+ auto key() const
+ -> decltype(PolicyTraits::mutable_key(std::declval<slot_type*>())) {
+ return PolicyTraits::mutable_key(this->slot());
}
mapped_type& mapped() const {
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h
index 735b738a9b..e12cc50a81 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h
@@ -169,34 +169,34 @@ constexpr bool ShouldAnyUseBase() {
}
template <typename T, typename V>
-using TupleElementMoveConstructible =
- typename std::conditional<std::is_reference<T>::value,
- std::is_convertible<V, T>,
- std::is_constructible<T, V&&>>::type;
-
-template <bool SizeMatches, class T, class... Vs>
-struct TupleMoveConstructible : std::false_type {};
-
-template <class... Ts, class... Vs>
-struct TupleMoveConstructible<true, CompressedTuple<Ts...>, Vs...>
- : std::integral_constant<
- bool, y_absl::conjunction<
- TupleElementMoveConstructible<Ts, Vs&&>...>::value> {};
-
-template <typename T>
-struct compressed_tuple_size;
-
-template <typename... Es>
-struct compressed_tuple_size<CompressedTuple<Es...>>
- : public std::integral_constant<std::size_t, sizeof...(Es)> {};
-
-template <class T, class... Vs>
-struct TupleItemsMoveConstructible
- : std::integral_constant<
- bool, TupleMoveConstructible<compressed_tuple_size<T>::value ==
- sizeof...(Vs),
- T, Vs...>::value> {};
-
+using TupleElementMoveConstructible =
+ typename std::conditional<std::is_reference<T>::value,
+ std::is_convertible<V, T>,
+ std::is_constructible<T, V&&>>::type;
+
+template <bool SizeMatches, class T, class... Vs>
+struct TupleMoveConstructible : std::false_type {};
+
+template <class... Ts, class... Vs>
+struct TupleMoveConstructible<true, CompressedTuple<Ts...>, Vs...>
+ : std::integral_constant<
+ bool, y_absl::conjunction<
+ TupleElementMoveConstructible<Ts, Vs&&>...>::value> {};
+
+template <typename T>
+struct compressed_tuple_size;
+
+template <typename... Es>
+struct compressed_tuple_size<CompressedTuple<Es...>>
+ : public std::integral_constant<std::size_t, sizeof...(Es)> {};
+
+template <class T, class... Vs>
+struct TupleItemsMoveConstructible
+ : std::integral_constant<
+ bool, TupleMoveConstructible<compressed_tuple_size<T>::value ==
+ sizeof...(Vs),
+ T, Vs...>::value> {};
+
} // namespace internal_compressed_tuple
// Helper class to perform the Empty Base Class Optimization.
@@ -241,23 +241,23 @@ class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple
explicit constexpr CompressedTuple(const Ts&... base)
: CompressedTuple::CompressedTupleImpl(y_absl::in_place, base...) {}
- template <typename First, typename... Vs,
+ template <typename First, typename... Vs,
y_absl::enable_if_t<
y_absl::conjunction<
// Ensure we are not hiding default copy/move constructors.
y_absl::negation<std::is_same<void(CompressedTuple),
- void(y_absl::decay_t<First>)>>,
- internal_compressed_tuple::TupleItemsMoveConstructible<
- CompressedTuple<Ts...>, First, Vs...>>::value,
+ void(y_absl::decay_t<First>)>>,
+ internal_compressed_tuple::TupleItemsMoveConstructible<
+ CompressedTuple<Ts...>, First, Vs...>>::value,
bool> = true>
- explicit constexpr CompressedTuple(First&& first, Vs&&... base)
+ explicit constexpr CompressedTuple(First&& first, Vs&&... base)
: CompressedTuple::CompressedTupleImpl(y_absl::in_place,
- y_absl::forward<First>(first),
+ y_absl::forward<First>(first),
y_absl::forward<Vs>(base)...) {}
template <int I>
ElemT<I>& get() & {
- return StorageT<I>::get();
+ return StorageT<I>::get();
}
template <int I>
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h
index 348bc8c0d0..669c8965ab 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h
@@ -18,31 +18,31 @@
#include <cassert>
#include <cstddef>
#include <memory>
-#include <new>
+#include <new>
#include <tuple>
#include <type_traits>
#include <utility>
-#include "y_absl/base/config.h"
+#include "y_absl/base/config.h"
#include "y_absl/memory/memory.h"
-#include "y_absl/meta/type_traits.h"
+#include "y_absl/meta/type_traits.h"
#include "y_absl/utility/utility.h"
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
-#include <sanitizer/asan_interface.h>
-#endif
-
-#ifdef ABSL_HAVE_MEMORY_SANITIZER
-#include <sanitizer/msan_interface.h>
-#endif
-
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#include <sanitizer/asan_interface.h>
+#endif
+
+#ifdef ABSL_HAVE_MEMORY_SANITIZER
+#include <sanitizer/msan_interface.h>
+#endif
+
namespace y_absl {
ABSL_NAMESPACE_BEGIN
namespace container_internal {
-template <size_t Alignment>
-struct alignas(Alignment) AlignedType {};
-
+template <size_t Alignment>
+struct alignas(Alignment) AlignedType {};
+
// Allocates at least n bytes aligned to the specified alignment.
// Alignment must be a power of 2. It must be positive.
//
@@ -54,14 +54,14 @@ template <size_t Alignment, class Alloc>
void* Allocate(Alloc* alloc, size_t n) {
static_assert(Alignment > 0, "");
assert(n && "n must be positive");
- using M = AlignedType<Alignment>;
+ using M = AlignedType<Alignment>;
using A = typename y_absl::allocator_traits<Alloc>::template rebind_alloc<M>;
using AT = typename y_absl::allocator_traits<Alloc>::template rebind_traits<M>;
- // On macOS, "mem_alloc" is a #define with one argument defined in
- // rpc/types.h, so we can't name the variable "mem_alloc" and initialize it
- // with the "foo(bar)" syntax.
- A my_mem_alloc(*alloc);
- void* p = AT::allocate(my_mem_alloc, (n + sizeof(M) - 1) / sizeof(M));
+ // On macOS, "mem_alloc" is a #define with one argument defined in
+ // rpc/types.h, so we can't name the variable "mem_alloc" and initialize it
+ // with the "foo(bar)" syntax.
+ A my_mem_alloc(*alloc);
+ void* p = AT::allocate(my_mem_alloc, (n + sizeof(M) - 1) / sizeof(M));
assert(reinterpret_cast<uintptr_t>(p) % Alignment == 0 &&
"allocator does not respect alignment");
return p;
@@ -73,14 +73,14 @@ template <size_t Alignment, class Alloc>
void Deallocate(Alloc* alloc, void* p, size_t n) {
static_assert(Alignment > 0, "");
assert(n && "n must be positive");
- using M = AlignedType<Alignment>;
+ using M = AlignedType<Alignment>;
using A = typename y_absl::allocator_traits<Alloc>::template rebind_alloc<M>;
using AT = typename y_absl::allocator_traits<Alloc>::template rebind_traits<M>;
- // On macOS, "mem_alloc" is a #define with one argument defined in
- // rpc/types.h, so we can't name the variable "mem_alloc" and initialize it
- // with the "foo(bar)" syntax.
- A my_mem_alloc(*alloc);
- AT::deallocate(my_mem_alloc, static_cast<M*>(p),
+ // On macOS, "mem_alloc" is a #define with one argument defined in
+ // rpc/types.h, so we can't name the variable "mem_alloc" and initialize it
+ // with the "foo(bar)" syntax.
+ A my_mem_alloc(*alloc);
+ AT::deallocate(my_mem_alloc, static_cast<M*>(p),
(n + sizeof(M) - 1) / sizeof(M));
}
@@ -217,10 +217,10 @@ DecomposeValue(F&& f, Arg&& arg) {
// Helper functions for asan and msan.
inline void SanitizerPoisonMemoryRegion(const void* m, size_t s) {
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
ASAN_POISON_MEMORY_REGION(m, s);
#endif
-#ifdef ABSL_HAVE_MEMORY_SANITIZER
+#ifdef ABSL_HAVE_MEMORY_SANITIZER
__msan_poison(m, s);
#endif
(void)m;
@@ -228,10 +228,10 @@ inline void SanitizerPoisonMemoryRegion(const void* m, size_t s) {
}
inline void SanitizerUnpoisonMemoryRegion(const void* m, size_t s) {
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
ASAN_UNPOISON_MEMORY_REGION(m, s);
#endif
-#ifdef ABSL_HAVE_MEMORY_SANITIZER
+#ifdef ABSL_HAVE_MEMORY_SANITIZER
__msan_unpoison(m, s);
#endif
(void)m;
@@ -258,8 +258,8 @@ namespace memory_internal {
// type, which is non-portable.
template <class Pair, class = std::true_type>
struct OffsetOf {
- static constexpr size_t kFirst = static_cast<size_t>(-1);
- static constexpr size_t kSecond = static_cast<size_t>(-1);
+ static constexpr size_t kFirst = static_cast<size_t>(-1);
+ static constexpr size_t kSecond = static_cast<size_t>(-1);
};
template <class Pair>
@@ -328,12 +328,12 @@ union map_slot_type {
map_slot_type() {}
~map_slot_type() = delete;
using value_type = std::pair<const K, V>;
- using mutable_value_type =
- std::pair<y_absl::remove_const_t<K>, y_absl::remove_const_t<V>>;
+ using mutable_value_type =
+ std::pair<y_absl::remove_const_t<K>, y_absl::remove_const_t<V>>;
value_type value;
mutable_value_type mutable_value;
- y_absl::remove_const_t<K> key;
+ y_absl::remove_const_t<K> key;
};
template <class K, class V>
@@ -359,20 +359,20 @@ struct map_slot_policy {
return slot->value;
}
- // When C++17 is available, we can use std::launder to provide mutable
- // access to the key for use in node handle.
-#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
- static K& mutable_key(slot_type* slot) {
- // Still check for kMutableKeys so that we can avoid calling std::launder
- // unless necessary because it can interfere with optimizations.
- return kMutableKeys::value ? slot->key
- : *std::launder(const_cast<K*>(
- std::addressof(slot->value.first)));
- }
-#else // !(defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606)
- static const K& mutable_key(slot_type* slot) { return key(slot); }
-#endif
-
+ // When C++17 is available, we can use std::launder to provide mutable
+ // access to the key for use in node handle.
+#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
+ static K& mutable_key(slot_type* slot) {
+ // Still check for kMutableKeys so that we can avoid calling std::launder
+ // unless necessary because it can interfere with optimizations.
+ return kMutableKeys::value ? slot->key
+ : *std::launder(const_cast<K*>(
+ std::addressof(slot->value.first)));
+ }
+#else // !(defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606)
+ static const K& mutable_key(slot_type* slot) { return key(slot); }
+#endif
+
static const K& key(const slot_type* slot) {
return kMutableKeys::value ? slot->key : slot->value.first;
}
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h
index c8975dbd90..ae486af9dc 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h
@@ -30,63 +30,63 @@ namespace container_internal {
// containers - that chain of allocators uses the same state and is
// thus easier to query for aggregate allocation information.
template <typename T>
-class CountingAllocator {
+class CountingAllocator {
public:
- using Allocator = std::allocator<T>;
- using AllocatorTraits = std::allocator_traits<Allocator>;
- using value_type = typename AllocatorTraits::value_type;
- using pointer = typename AllocatorTraits::pointer;
- using const_pointer = typename AllocatorTraits::const_pointer;
- using size_type = typename AllocatorTraits::size_type;
- using difference_type = typename AllocatorTraits::difference_type;
-
- CountingAllocator() = default;
- explicit CountingAllocator(int64_t* bytes_used) : bytes_used_(bytes_used) {}
- CountingAllocator(int64_t* bytes_used, int64_t* instance_count)
- : bytes_used_(bytes_used), instance_count_(instance_count) {}
+ using Allocator = std::allocator<T>;
+ using AllocatorTraits = std::allocator_traits<Allocator>;
+ using value_type = typename AllocatorTraits::value_type;
+ using pointer = typename AllocatorTraits::pointer;
+ using const_pointer = typename AllocatorTraits::const_pointer;
+ using size_type = typename AllocatorTraits::size_type;
+ using difference_type = typename AllocatorTraits::difference_type;
+
+ CountingAllocator() = default;
+ explicit CountingAllocator(int64_t* bytes_used) : bytes_used_(bytes_used) {}
+ CountingAllocator(int64_t* bytes_used, int64_t* instance_count)
+ : bytes_used_(bytes_used), instance_count_(instance_count) {}
template <typename U>
CountingAllocator(const CountingAllocator<U>& x)
- : bytes_used_(x.bytes_used_), instance_count_(x.instance_count_) {}
-
- pointer allocate(
- size_type n,
- typename AllocatorTraits::const_void_pointer hint = nullptr) {
- Allocator allocator;
- pointer ptr = AllocatorTraits::allocate(allocator, n, hint);
- if (bytes_used_ != nullptr) {
- *bytes_used_ += n * sizeof(T);
- }
- return ptr;
+ : bytes_used_(x.bytes_used_), instance_count_(x.instance_count_) {}
+
+ pointer allocate(
+ size_type n,
+ typename AllocatorTraits::const_void_pointer hint = nullptr) {
+ Allocator allocator;
+ pointer ptr = AllocatorTraits::allocate(allocator, n, hint);
+ if (bytes_used_ != nullptr) {
+ *bytes_used_ += n * sizeof(T);
+ }
+ return ptr;
}
void deallocate(pointer p, size_type n) {
- Allocator allocator;
- AllocatorTraits::deallocate(allocator, p, n);
- if (bytes_used_ != nullptr) {
- *bytes_used_ -= n * sizeof(T);
- }
- }
-
- template <typename U, typename... Args>
- void construct(U* p, Args&&... args) {
- Allocator allocator;
- AllocatorTraits::construct(allocator, p, std::forward<Args>(args)...);
- if (instance_count_ != nullptr) {
- *instance_count_ += 1;
- }
+ Allocator allocator;
+ AllocatorTraits::deallocate(allocator, p, n);
+ if (bytes_used_ != nullptr) {
+ *bytes_used_ -= n * sizeof(T);
+ }
}
- template <typename U>
- void destroy(U* p) {
- Allocator allocator;
- AllocatorTraits::destroy(allocator, p);
- if (instance_count_ != nullptr) {
- *instance_count_ -= 1;
- }
- }
-
- template <typename U>
+ template <typename U, typename... Args>
+ void construct(U* p, Args&&... args) {
+ Allocator allocator;
+ AllocatorTraits::construct(allocator, p, std::forward<Args>(args)...);
+ if (instance_count_ != nullptr) {
+ *instance_count_ += 1;
+ }
+ }
+
+ template <typename U>
+ void destroy(U* p) {
+ Allocator allocator;
+ AllocatorTraits::destroy(allocator, p);
+ if (instance_count_ != nullptr) {
+ *instance_count_ -= 1;
+ }
+ }
+
+ template <typename U>
class rebind {
public:
using other = CountingAllocator<U>;
@@ -94,8 +94,8 @@ class CountingAllocator {
friend bool operator==(const CountingAllocator& a,
const CountingAllocator& b) {
- return a.bytes_used_ == b.bytes_used_ &&
- a.instance_count_ == b.instance_count_;
+ return a.bytes_used_ == b.bytes_used_ &&
+ a.instance_count_ == b.instance_count_;
}
friend bool operator!=(const CountingAllocator& a,
@@ -103,8 +103,8 @@ class CountingAllocator {
return !(a == b);
}
- int64_t* bytes_used_ = nullptr;
- int64_t* instance_count_ = nullptr;
+ int64_t* bytes_used_ = nullptr;
+ int64_t* instance_count_ = nullptr;
};
} // namespace container_internal
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h
index 68a18058d1..1407979619 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h
@@ -53,7 +53,7 @@
#include "y_absl/base/config.h"
#include "y_absl/hash/hash.h"
-#include "y_absl/strings/cord.h"
+#include "y_absl/strings/cord.h"
#include "y_absl/strings/string_view.h"
namespace y_absl {
@@ -73,9 +73,9 @@ struct StringHash {
size_t operator()(y_absl::string_view v) const {
return y_absl::Hash<y_absl::string_view>{}(v);
}
- size_t operator()(const y_absl::Cord& v) const {
- return y_absl::Hash<y_absl::Cord>{}(v);
- }
+ size_t operator()(const y_absl::Cord& v) const {
+ return y_absl::Hash<y_absl::Cord>{}(v);
+ }
};
struct StringEq {
@@ -104,8 +104,8 @@ template <>
struct HashEq<TString> : StringHashEq {};
template <>
struct HashEq<y_absl::string_view> : StringHashEq {};
-template <>
-struct HashEq<y_absl::Cord> : StringHashEq {};
+template <>
+struct HashEq<y_absl::Cord> : StringHashEq {};
// Supports heterogeneous lookup for pointers and smart pointers.
template <class T>
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h
index 33f704fc4b..b4d8d913ee 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h
@@ -17,7 +17,7 @@
#include <cstddef>
#include <memory>
-#include <new>
+#include <new>
#include <type_traits>
#include <utility>
@@ -30,34 +30,34 @@ namespace container_internal {
// Defines how slots are initialized/destroyed/moved.
template <class Policy, class = void>
struct hash_policy_traits {
- // The type of the keys stored in the hashtable.
- using key_type = typename Policy::key_type;
-
+ // The type of the keys stored in the hashtable.
+ using key_type = typename Policy::key_type;
+
private:
struct ReturnKey {
- // When C++17 is available, we can use std::launder to provide mutable
- // access to the key for use in node handle.
-#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
- template <class Key,
- y_absl::enable_if_t<std::is_lvalue_reference<Key>::value, int> = 0>
- static key_type& Impl(Key&& k, int) {
- return *std::launder(
- const_cast<key_type*>(std::addressof(std::forward<Key>(k))));
- }
-#endif
-
- template <class Key>
- static Key Impl(Key&& k, char) {
- return std::forward<Key>(k);
- }
-
+ // When C++17 is available, we can use std::launder to provide mutable
+ // access to the key for use in node handle.
+#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
+ template <class Key,
+ y_absl::enable_if_t<std::is_lvalue_reference<Key>::value, int> = 0>
+ static key_type& Impl(Key&& k, int) {
+ return *std::launder(
+ const_cast<key_type*>(std::addressof(std::forward<Key>(k))));
+ }
+#endif
+
+ template <class Key>
+ static Key Impl(Key&& k, char) {
+ return std::forward<Key>(k);
+ }
+
// When Key=T&, we forward the lvalue reference.
// When Key=T, we return by value to avoid a dangling reference.
// eg, for string_hash_map.
template <class Key, class... Args>
- auto operator()(Key&& k, const Args&...) const
- -> decltype(Impl(std::forward<Key>(k), 0)) {
- return Impl(std::forward<Key>(k), 0);
+ auto operator()(Key&& k, const Args&...) const
+ -> decltype(Impl(std::forward<Key>(k), 0)) {
+ return Impl(std::forward<Key>(k), 0);
}
};
@@ -173,7 +173,7 @@ struct hash_policy_traits {
// Returns the "key" portion of the slot.
// Used for node handle manipulation.
template <class P = Policy>
- static auto mutable_key(slot_type* slot)
+ static auto mutable_key(slot_type* slot)
-> decltype(P::apply(ReturnKey(), element(slot))) {
return P::apply(ReturnKey(), element(slot));
}
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc
index 6017ac9bb0..e20e5642d6 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc
@@ -65,12 +65,12 @@ void HashtablezInfo::PrepareForSampling() {
capacity.store(0, std::memory_order_relaxed);
size.store(0, std::memory_order_relaxed);
num_erases.store(0, std::memory_order_relaxed);
- num_rehashes.store(0, std::memory_order_relaxed);
+ num_rehashes.store(0, std::memory_order_relaxed);
max_probe_length.store(0, std::memory_order_relaxed);
total_probe_length.store(0, std::memory_order_relaxed);
hashes_bitwise_or.store(0, std::memory_order_relaxed);
hashes_bitwise_and.store(~size_t{}, std::memory_order_relaxed);
- hashes_bitwise_xor.store(0, std::memory_order_relaxed);
+ hashes_bitwise_xor.store(0, std::memory_order_relaxed);
max_reserve.store(0, std::memory_order_relaxed);
create_time = y_absl::Now();
@@ -93,9 +93,9 @@ static bool ShouldForceSampling() {
if (ABSL_PREDICT_TRUE(state == kDontForce)) return false;
if (state == kUninitialized) {
- state = ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)()
- ? kForce
- : kDontForce;
+ state = ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)()
+ ? kForce
+ : kDontForce;
global_state.store(state, std::memory_order_relaxed);
}
return state == kForce;
@@ -146,7 +146,7 @@ void RecordInsertSlow(HashtablezInfo* info, size_t hash,
// SwissTables probe in groups of 16, so scale this to count items probes and
// not offset from desired.
size_t probe_length = distance_from_desired;
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
probe_length /= 16;
#else
probe_length /= 8;
@@ -154,7 +154,7 @@ void RecordInsertSlow(HashtablezInfo* info, size_t hash,
info->hashes_bitwise_and.fetch_and(hash, std::memory_order_relaxed);
info->hashes_bitwise_or.fetch_or(hash, std::memory_order_relaxed);
- info->hashes_bitwise_xor.fetch_xor(hash, std::memory_order_relaxed);
+ info->hashes_bitwise_xor.fetch_xor(hash, std::memory_order_relaxed);
info->max_probe_length.store(
std::max(info->max_probe_length.load(std::memory_order_relaxed),
probe_length),
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h
index 8521ee754a..656be23f07 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h
@@ -74,12 +74,12 @@ struct HashtablezInfo : public profiling_internal::Sample<HashtablezInfo> {
std::atomic<size_t> capacity;
std::atomic<size_t> size;
std::atomic<size_t> num_erases;
- std::atomic<size_t> num_rehashes;
+ std::atomic<size_t> num_rehashes;
std::atomic<size_t> max_probe_length;
std::atomic<size_t> total_probe_length;
std::atomic<size_t> hashes_bitwise_or;
std::atomic<size_t> hashes_bitwise_and;
- std::atomic<size_t> hashes_bitwise_xor;
+ std::atomic<size_t> hashes_bitwise_xor;
std::atomic<size_t> max_reserve;
// All of the fields below are set by `PrepareForSampling`, they must not be
@@ -95,18 +95,18 @@ struct HashtablezInfo : public profiling_internal::Sample<HashtablezInfo> {
};
inline void RecordRehashSlow(HashtablezInfo* info, size_t total_probe_length) {
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
total_probe_length /= 16;
#else
total_probe_length /= 8;
#endif
info->total_probe_length.store(total_probe_length, std::memory_order_relaxed);
info->num_erases.store(0, std::memory_order_relaxed);
- // There is only one concurrent writer, so `load` then `store` is sufficient
- // instead of using `fetch_add`.
- info->num_rehashes.store(
- 1 + info->num_rehashes.load(std::memory_order_relaxed),
- std::memory_order_relaxed);
+ // There is only one concurrent writer, so `load` then `store` is sufficient
+ // instead of using `fetch_add`.
+ info->num_rehashes.store(
+ 1 + info->num_rehashes.load(std::memory_order_relaxed),
+ std::memory_order_relaxed);
}
inline void RecordReservationSlow(HashtablezInfo* info,
@@ -127,8 +127,8 @@ inline void RecordStorageChangedSlow(HashtablezInfo* info, size_t size,
info->capacity.store(capacity, std::memory_order_relaxed);
if (size == 0) {
// This is a clear, reset the total/num_erases too.
- info->total_probe_length.store(0, std::memory_order_relaxed);
- info->num_erases.store(0, std::memory_order_relaxed);
+ info->total_probe_length.store(0, std::memory_order_relaxed);
+ info->num_erases.store(0, std::memory_order_relaxed);
}
}
@@ -137,21 +137,21 @@ void RecordInsertSlow(HashtablezInfo* info, size_t hash,
inline void RecordEraseSlow(HashtablezInfo* info) {
info->size.fetch_sub(1, std::memory_order_relaxed);
- // There is only one concurrent writer, so `load` then `store` is sufficient
- // instead of using `fetch_add`.
- info->num_erases.store(
- 1 + info->num_erases.load(std::memory_order_relaxed),
- std::memory_order_relaxed);
+ // There is only one concurrent writer, so `load` then `store` is sufficient
+ // instead of using `fetch_add`.
+ info->num_erases.store(
+ 1 + info->num_erases.load(std::memory_order_relaxed),
+ std::memory_order_relaxed);
}
HashtablezInfo* SampleSlow(int64_t* next_sample, size_t inline_element_size);
void UnsampleSlow(HashtablezInfo* info);
-#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
-#error ABSL_INTERNAL_HASHTABLEZ_SAMPLE cannot be directly set
-#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
-
-#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
+#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
+#error ABSL_INTERNAL_HASHTABLEZ_SAMPLE cannot be directly set
+#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
+
+#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
class HashtablezInfoHandle {
public:
explicit HashtablezInfoHandle() : info_(nullptr) {}
@@ -213,29 +213,29 @@ class HashtablezInfoHandle {
friend class HashtablezInfoHandlePeer;
HashtablezInfo* info_;
};
-#else
-// Ensure that when Hashtablez is turned off at compile time, HashtablezInfo can
-// be removed by the linker, in order to reduce the binary size.
-class HashtablezInfoHandle {
- public:
- explicit HashtablezInfoHandle() = default;
- explicit HashtablezInfoHandle(std::nullptr_t) {}
-
- inline void RecordStorageChanged(size_t /*size*/, size_t /*capacity*/) {}
- inline void RecordRehash(size_t /*total_probe_length*/) {}
+#else
+// Ensure that when Hashtablez is turned off at compile time, HashtablezInfo can
+// be removed by the linker, in order to reduce the binary size.
+class HashtablezInfoHandle {
+ public:
+ explicit HashtablezInfoHandle() = default;
+ explicit HashtablezInfoHandle(std::nullptr_t) {}
+
+ inline void RecordStorageChanged(size_t /*size*/, size_t /*capacity*/) {}
+ inline void RecordRehash(size_t /*total_probe_length*/) {}
inline void RecordReservation(size_t /*target_capacity*/) {}
inline void RecordClearedReservation() {}
- inline void RecordInsert(size_t /*hash*/, size_t /*distance_from_desired*/) {}
- inline void RecordErase() {}
-
- friend inline void swap(HashtablezInfoHandle& /*lhs*/,
- HashtablezInfoHandle& /*rhs*/) {}
-};
+ inline void RecordInsert(size_t /*hash*/, size_t /*distance_from_desired*/) {}
+ inline void RecordErase() {}
+
+ friend inline void swap(HashtablezInfoHandle& /*lhs*/,
+ HashtablezInfoHandle& /*rhs*/) {}
+};
#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
extern ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample;
-#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
+#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
// Returns an RAII sampling handle that manages registration and unregistation
// with the global sampler.
@@ -272,7 +272,7 @@ void SetHashtablezMaxSamples(int32_t max);
// initialization of static storage duration objects.
// The definition of this constant is weak, which allows us to inject a
// different value for it at link time.
-extern "C" bool ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)();
+extern "C" bool ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)();
} // namespace container_internal
ABSL_NAMESPACE_END
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc
index 79a3122981..4536de40c8 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc
@@ -21,8 +21,8 @@ ABSL_NAMESPACE_BEGIN
namespace container_internal {
// See hashtablez_sampler.h for details.
-extern "C" ABSL_ATTRIBUTE_WEAK bool ABSL_INTERNAL_C_SYMBOL(
- AbslContainerInternalSampleEverything)() {
+extern "C" ABSL_ATTRIBUTE_WEAK bool ABSL_INTERNAL_C_SYMBOL(
+ AbslContainerInternalSampleEverything)() {
return false;
}
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/have_sse.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/have_sse.h
index e75e1a16d3..58da3b3163 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/have_sse.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/have_sse.h
@@ -16,34 +16,34 @@
#ifndef ABSL_CONTAINER_INTERNAL_HAVE_SSE_H_
#define ABSL_CONTAINER_INTERNAL_HAVE_SSE_H_
-#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
#if defined(__SSE2__) || \
(defined(_MSC_VER) && \
(defined(_M_X64) || (defined(_M_IX86) && _M_IX86_FP >= 2)))
-#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 1
+#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 1
#else
-#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 0
+#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 0
#endif
#endif
-#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
+#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
#ifdef __SSSE3__
-#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 1
+#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 1
#else
-#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 0
+#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 0
#endif
#endif
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 && \
- !ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 && \
+ !ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
#error "Bad configuration!"
#endif
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
#include <emmintrin.h>
#endif
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
#include <tmmintrin.h>
#endif
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h
index e6488e843e..b5cd516154 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h
@@ -36,13 +36,13 @@ namespace y_absl {
ABSL_NAMESPACE_BEGIN
namespace inlined_vector_internal {
-// GCC does not deal very well with the below code
-#if !defined(__clang__) && defined(__GNUC__)
-#pragma GCC diagnostic push
+// GCC does not deal very well with the below code
+#if !defined(__clang__) && defined(__GNUC__)
+#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif
-
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
template <typename A>
using AllocatorTraits = std::allocator_traits<A>;
template <typename A>
@@ -110,7 +110,7 @@ struct Allocation {
Pointer<A> data;
SizeType<A> capacity;
};
-
+
template <typename A,
bool IsOverAligned =
(alignof(ValueType<A>) > ABSL_INTERNAL_DEFAULT_NEW_ALIGNMENT)>
@@ -119,13 +119,13 @@ struct MallocAdapter {
return {AllocatorTraits<A>::allocate(allocator, requested_capacity),
requested_capacity};
}
-
+
static void Deallocate(A& allocator, Pointer<A> pointer,
SizeType<A> capacity) {
AllocatorTraits<A>::deallocate(allocator, pointer, capacity);
}
};
-
+
template <typename A, typename ValueAdapter>
void ConstructElements(NoTypeDeduction<A>& allocator,
Pointer<A> construct_first, ValueAdapter& values,
@@ -303,14 +303,14 @@ class Storage {
: metadata_(allocator, /* size and is_allocated */ 0) {}
~Storage() {
- if (GetSizeAndIsAllocated() == 0) {
- // Empty and not allocated; nothing to do.
+ if (GetSizeAndIsAllocated() == 0) {
+ // Empty and not allocated; nothing to do.
} else if (IsMemcpyOk<A>::value) {
- // No destructors need to be run; just deallocate if necessary.
- DeallocateIfAllocated();
- } else {
- DestroyContents();
- }
+ // No destructors need to be run; just deallocate if necessary.
+ DeallocateIfAllocated();
+ } else {
+ DestroyContents();
+ }
}
// ---------------------------------------------------------------------------
@@ -364,8 +364,8 @@ class Storage {
// Storage Member Mutators
// ---------------------------------------------------------------------------
- ABSL_ATTRIBUTE_NOINLINE void InitFrom(const Storage& other);
-
+ ABSL_ATTRIBUTE_NOINLINE void InitFrom(const Storage& other);
+
template <typename ValueAdapter>
void Initialize(ValueAdapter values, SizeType<A> new_size);
@@ -441,8 +441,8 @@ class Storage {
}
private:
- ABSL_ATTRIBUTE_NOINLINE void DestroyContents();
-
+ ABSL_ATTRIBUTE_NOINLINE void DestroyContents();
+
using Metadata = container_internal::CompressedTuple<A, SizeType<A>>;
struct Allocated {
@@ -459,51 +459,51 @@ class Storage {
Inlined inlined;
};
- template <typename... Args>
+ template <typename... Args>
ABSL_ATTRIBUTE_NOINLINE Reference<A> EmplaceBackSlow(Args&&... args);
-
+
Metadata metadata_;
Data data_;
};
template <typename T, size_t N, typename A>
-void Storage<T, N, A>::DestroyContents() {
+void Storage<T, N, A>::DestroyContents() {
Pointer<A> data = GetIsAllocated() ? GetAllocatedData() : GetInlinedData();
DestroyElements<A>(GetAllocator(), data, GetSize());
- DeallocateIfAllocated();
-}
-
-template <typename T, size_t N, typename A>
-void Storage<T, N, A>::InitFrom(const Storage& other) {
+ DeallocateIfAllocated();
+}
+
+template <typename T, size_t N, typename A>
+void Storage<T, N, A>::InitFrom(const Storage& other) {
const SizeType<A> n = other.GetSize();
- assert(n > 0); // Empty sources handled handled in caller.
+ assert(n > 0); // Empty sources handled handled in caller.
ConstPointer<A> src;
Pointer<A> dst;
- if (!other.GetIsAllocated()) {
- dst = GetInlinedData();
- src = other.GetInlinedData();
- } else {
- // Because this is only called from the `InlinedVector` constructors, it's
- // safe to take on the allocation with size `0`. If `ConstructElements(...)`
- // throws, deallocation will be automatically handled by `~Storage()`.
+ if (!other.GetIsAllocated()) {
+ dst = GetInlinedData();
+ src = other.GetInlinedData();
+ } else {
+ // Because this is only called from the `InlinedVector` constructors, it's
+ // safe to take on the allocation with size `0`. If `ConstructElements(...)`
+ // throws, deallocation will be automatically handled by `~Storage()`.
SizeType<A> requested_capacity = ComputeCapacity(GetInlinedCapacity(), n);
Allocation<A> allocation =
MallocAdapter<A>::Allocate(GetAllocator(), requested_capacity);
SetAllocation(allocation);
dst = allocation.data;
- src = other.GetAllocatedData();
- }
+ src = other.GetAllocatedData();
+ }
if (IsMemcpyOk<A>::value) {
std::memcpy(reinterpret_cast<char*>(dst),
reinterpret_cast<const char*>(src), n * sizeof(ValueType<A>));
- } else {
+ } else {
auto values = IteratorValueAdapter<A, ConstPointer<A>>(src);
ConstructElements<A>(GetAllocator(), dst, values, n);
- }
- GetSizeAndIsAllocated() = other.GetSizeAndIsAllocated();
-}
-
-template <typename T, size_t N, typename A>
+ }
+ GetSizeAndIsAllocated() = other.GetSizeAndIsAllocated();
+}
+
+template <typename T, size_t N, typename A>
template <typename ValueAdapter>
auto Storage<T, N, A>::Initialize(ValueAdapter values, SizeType<A> new_size)
-> void {
@@ -585,20 +585,20 @@ auto Storage<T, N, A>::Resize(ValueAdapter values, SizeType<A> new_size)
Pointer<A> const base = storage_view.data;
const SizeType<A> size = storage_view.size;
A& alloc = GetAllocator();
- if (new_size <= size) {
- // Destroy extra old elements.
+ if (new_size <= size) {
+ // Destroy extra old elements.
DestroyElements<A>(alloc, base + new_size, size - new_size);
- } else if (new_size <= storage_view.capacity) {
- // Construct new elements in place.
+ } else if (new_size <= storage_view.capacity) {
+ // Construct new elements in place.
ConstructElements<A>(alloc, base + size, values, new_size - size);
- } else {
- // Steps:
- // a. Allocate new backing store.
- // b. Construct new elements in new backing store.
- // c. Move existing elements from old backing store to now.
- // d. Destroy all elements in old backing store.
- // Use transactional wrappers for the first two steps so we can roll
- // back if necessary due to exceptions.
+ } else {
+ // Steps:
+ // a. Allocate new backing store.
+ // b. Construct new elements in new backing store.
+ // c. Move existing elements from old backing store to now.
+ // d. Destroy all elements in old backing store.
+ // Use transactional wrappers for the first two steps so we can roll
+ // back if necessary due to exceptions.
AllocationTransaction<A> allocation_tx(alloc);
SizeType<A> requested_capacity =
ComputeCapacity(storage_view.capacity, new_size);
@@ -717,20 +717,20 @@ template <typename... Args>
auto Storage<T, N, A>::EmplaceBack(Args&&... args) -> Reference<A> {
StorageView<A> storage_view = MakeStorageView();
const SizeType<A> n = storage_view.size;
- if (ABSL_PREDICT_TRUE(n != storage_view.capacity)) {
- // Fast path; new element fits.
+ if (ABSL_PREDICT_TRUE(n != storage_view.capacity)) {
+ // Fast path; new element fits.
Pointer<A> last_ptr = storage_view.data + n;
AllocatorTraits<A>::construct(GetAllocator(), last_ptr,
std::forward<Args>(args)...);
- AddSize(1);
- return *last_ptr;
- }
- // TODO(b/173712035): Annotate with musttail attribute to prevent regression.
- return EmplaceBackSlow(std::forward<Args>(args)...);
-}
-
-template <typename T, size_t N, typename A>
-template <typename... Args>
+ AddSize(1);
+ return *last_ptr;
+ }
+ // TODO(b/173712035): Annotate with musttail attribute to prevent regression.
+ return EmplaceBackSlow(std::forward<Args>(args)...);
+}
+
+template <typename T, size_t N, typename A>
+template <typename... Args>
auto Storage<T, N, A>::EmplaceBackSlow(Args&&... args) -> Reference<A> {
StorageView<A> storage_view = MakeStorageView();
AllocationTransaction<A> allocation_tx(GetAllocator());
@@ -740,24 +740,24 @@ auto Storage<T, N, A>::EmplaceBackSlow(Args&&... args) -> Reference<A> {
Pointer<A> construct_data = allocation_tx.Allocate(requested_capacity);
Pointer<A> last_ptr = construct_data + storage_view.size;
- // Construct new element.
+ // Construct new element.
AllocatorTraits<A>::construct(GetAllocator(), last_ptr,
std::forward<Args>(args)...);
- // Move elements from old backing store to new backing store.
- ABSL_INTERNAL_TRY {
+ // Move elements from old backing store to new backing store.
+ ABSL_INTERNAL_TRY {
ConstructElements<A>(GetAllocator(), allocation_tx.GetData(), move_values,
storage_view.size);
}
- ABSL_INTERNAL_CATCH_ANY {
+ ABSL_INTERNAL_CATCH_ANY {
AllocatorTraits<A>::destroy(GetAllocator(), last_ptr);
- ABSL_INTERNAL_RETHROW;
- }
- // Destroy elements in old backing store.
+ ABSL_INTERNAL_RETHROW;
+ }
+ // Destroy elements in old backing store.
DestroyElements<A>(GetAllocator(), storage_view.data, storage_view.size);
- DeallocateIfAllocated();
+ DeallocateIfAllocated();
SetAllocation(std::move(allocation_tx).Release());
- SetIsAllocated();
+ SetIsAllocated();
AddSize(1);
return *last_ptr;
}
@@ -921,10 +921,10 @@ auto Storage<T, N, A>::Swap(Storage* other_storage_ptr) -> void {
}
// End ignore "array-bounds" and "maybe-uninitialized"
-#if !defined(__clang__) && defined(__GNUC__)
-#pragma GCC diagnostic pop
-#endif
-
+#if !defined(__clang__) && defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
} // namespace inlined_vector_internal
ABSL_NAMESPACE_END
} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h
index 4c3f668943..327d910d60 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h
@@ -163,7 +163,7 @@
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
-
+
#include <ostream>
#include <util/generic/string.h>
#include <tuple>
@@ -171,16 +171,16 @@
#include <typeinfo>
#include <utility>
-#include "y_absl/base/config.h"
+#include "y_absl/base/config.h"
#include "y_absl/meta/type_traits.h"
#include "y_absl/strings/str_cat.h"
#include "y_absl/types/span.h"
#include "y_absl/utility/utility.h"
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
-#include <sanitizer/asan_interface.h>
-#endif
-
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#include <sanitizer/asan_interface.h>
+#endif
+
#if defined(__GXX_RTTI)
#define ABSL_INTERNAL_HAS_CXA_DEMANGLE
#endif
@@ -404,7 +404,7 @@ class LayoutImpl<std::tuple<Elements...>, y_absl::index_sequence<SizeSeq...>,
constexpr size_t Offset() const {
static_assert(N < NumOffsets, "Index out of bounds");
return adl_barrier::Align(
- Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * size_[N - 1],
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * size_[N - 1],
ElementAlignment<N>::value);
}
@@ -597,7 +597,7 @@ class LayoutImpl<std::tuple<Elements...>, y_absl::index_sequence<SizeSeq...>,
constexpr size_t AllocSize() const {
static_assert(NumTypes == NumSizes, "You must specify sizes of all fields");
return Offset<NumTypes - 1>() +
- SizeOf<ElementType<NumTypes - 1>>::value * size_[NumTypes - 1];
+ SizeOf<ElementType<NumTypes - 1>>::value * size_[NumTypes - 1];
}
// If built with --config=asan, poisons padding bytes (if any) in the
@@ -616,12 +616,12 @@ class LayoutImpl<std::tuple<Elements...>, y_absl::index_sequence<SizeSeq...>,
void PoisonPadding(const Char* p) const {
static_assert(N < NumOffsets, "Index out of bounds");
(void)p;
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
+#ifdef ABSL_HAVE_ADDRESS_SANITIZER
PoisonPadding<Char, N - 1>(p);
// The `if` is an optimization. It doesn't affect the observable behaviour.
if (ElementAlignment<N - 1>::value % ElementAlignment<N>::value) {
size_t start =
- Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * size_[N - 1];
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * size_[N - 1];
ASAN_POISON_MEMORY_REGION(p + start, Offset<N>() - start);
}
#endif
@@ -645,7 +645,7 @@ class LayoutImpl<std::tuple<Elements...>, y_absl::index_sequence<SizeSeq...>,
// produce "unsigned*" where another produces "unsigned int *".
TString DebugString() const {
const auto offsets = Offsets();
- const size_t sizes[] = {SizeOf<ElementType<OffsetSeq>>::value...};
+ const size_t sizes[] = {SizeOf<ElementType<OffsetSeq>>::value...};
const TString types[] = {
adl_barrier::TypeName<ElementType<OffsetSeq>>()...};
TString res = y_absl::StrCat("@0", types[0], "(", sizes[0], ")");
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc
index bf2a15a678..5da7c92dbc 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc
@@ -33,7 +33,7 @@ constexpr size_t Group::kWidth;
// Returns "random" seed.
inline size_t RandomSeed() {
-#ifdef ABSL_HAVE_THREAD_LOCAL
+#ifdef ABSL_HAVE_THREAD_LOCAL
static thread_local size_t counter = 0;
size_t value = ++counter;
#else // ABSL_HAVE_THREAD_LOCAL
@@ -51,17 +51,17 @@ bool ShouldInsertBackwards(size_t hash, const ctrl_t* ctrl) {
void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity) {
assert(ctrl[capacity] == ctrl_t::kSentinel);
- assert(IsValidCapacity(capacity));
+ assert(IsValidCapacity(capacity));
for (ctrl_t* pos = ctrl; pos < ctrl + capacity; pos += Group::kWidth) {
- Group{pos}.ConvertSpecialToEmptyAndFullToDeleted(pos);
- }
- // Copy the cloned ctrl bytes.
+ Group{pos}.ConvertSpecialToEmptyAndFullToDeleted(pos);
+ }
+ // Copy the cloned ctrl bytes.
std::memcpy(ctrl + capacity + 1, ctrl, NumClonedBytes());
ctrl[capacity] = ctrl_t::kSentinel;
-}
+}
// Extern template instantiotion for inline function.
template FindInfo find_first_non_full(const ctrl_t*, size_t, size_t);
-
+
} // namespace container_internal
ABSL_NAMESPACE_END
} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h
index 8f45559b31..a493faea66 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h
@@ -114,7 +114,7 @@
#include <utility>
#include "y_absl/base/internal/endian.h"
-#include "y_absl/base/optimization.h"
+#include "y_absl/base/optimization.h"
#include "y_absl/base/port.h"
#include "y_absl/container/internal/common.h"
#include "y_absl/container/internal/compressed_tuple.h"
@@ -125,23 +125,23 @@
#include "y_absl/container/internal/have_sse.h"
#include "y_absl/memory/memory.h"
#include "y_absl/meta/type_traits.h"
-#include "y_absl/numeric/bits.h"
+#include "y_absl/numeric/bits.h"
#include "y_absl/utility/utility.h"
namespace y_absl {
ABSL_NAMESPACE_BEGIN
namespace container_internal {
-template <typename AllocType>
-void SwapAlloc(AllocType& lhs, AllocType& rhs,
- std::true_type /* propagate_on_container_swap */) {
- using std::swap;
- swap(lhs, rhs);
-}
-template <typename AllocType>
-void SwapAlloc(AllocType& /*lhs*/, AllocType& /*rhs*/,
- std::false_type /* propagate_on_container_swap */) {}
-
+template <typename AllocType>
+void SwapAlloc(AllocType& lhs, AllocType& rhs,
+ std::true_type /* propagate_on_container_swap */) {
+ using std::swap;
+ swap(lhs, rhs);
+}
+template <typename AllocType>
+void SwapAlloc(AllocType& /*lhs*/, AllocType& /*rhs*/,
+ std::false_type /* propagate_on_container_swap */) {}
+
template <size_t Width>
class probe_seq {
public:
@@ -189,19 +189,19 @@ struct IsDecomposable<
// TODO(alkis): Switch to std::is_nothrow_swappable when gcc/clang supports it.
template <class T>
-constexpr bool IsNoThrowSwappable(std::true_type = {} /* is_swappable */) {
+constexpr bool IsNoThrowSwappable(std::true_type = {} /* is_swappable */) {
using std::swap;
return noexcept(swap(std::declval<T&>(), std::declval<T&>()));
}
-template <class T>
-constexpr bool IsNoThrowSwappable(std::false_type /* is_swappable */) {
- return false;
+template <class T>
+constexpr bool IsNoThrowSwappable(std::false_type /* is_swappable */) {
+ return false;
}
template <typename T>
-uint32_t TrailingZeros(T x) {
- ABSL_INTERNAL_ASSUME(x != 0);
- return countr_zero(x);
+uint32_t TrailingZeros(T x) {
+ ABSL_INTERNAL_ASSUME(x != 0);
+ return countr_zero(x);
}
// An abstraction over a bitmask. It provides an easy way to iterate through the
@@ -231,24 +231,24 @@ class BitMask {
}
explicit operator bool() const { return mask_ != 0; }
int operator*() const { return LowestBitSet(); }
- uint32_t LowestBitSet() const {
+ uint32_t LowestBitSet() const {
return container_internal::TrailingZeros(mask_) >> Shift;
}
- uint32_t HighestBitSet() const {
- return static_cast<uint32_t>((bit_width(mask_) - 1) >> Shift);
+ uint32_t HighestBitSet() const {
+ return static_cast<uint32_t>((bit_width(mask_) - 1) >> Shift);
}
BitMask begin() const { return *this; }
BitMask end() const { return BitMask(0); }
- uint32_t TrailingZeros() const {
+ uint32_t TrailingZeros() const {
return container_internal::TrailingZeros(mask_) >> Shift;
}
- uint32_t LeadingZeros() const {
+ uint32_t LeadingZeros() const {
constexpr int total_significant_bits = SignificantBits << Shift;
constexpr int extra_bits = sizeof(T) * 8 - total_significant_bits;
- return countl_zero(mask_ << extra_bits) >> Shift;
+ return countl_zero(mask_ << extra_bits) >> Shift;
}
private:
@@ -331,7 +331,7 @@ inline bool IsFull(ctrl_t c) { return c >= static_cast<ctrl_t>(0); }
inline bool IsDeleted(ctrl_t c) { return c == ctrl_t::kDeleted; }
inline bool IsEmptyOrDeleted(ctrl_t c) { return c < ctrl_t::kSentinel; }
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
// https://github.com/abseil/abseil-cpp/issues/209
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87853
@@ -365,7 +365,7 @@ struct GroupSse2Impl {
// Returns a bitmask representing the positions of empty slots.
BitMask<uint32_t, kWidth> MatchEmpty() const {
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
// This only works because ctrl_t::kEmpty is -128.
return BitMask<uint32_t, kWidth>(
_mm_movemask_epi8(_mm_sign_epi8(ctrl, ctrl)));
@@ -384,14 +384,14 @@ struct GroupSse2Impl {
// Returns the number of trailing empty or deleted elements in the group.
uint32_t CountLeadingEmptyOrDeleted() const {
auto special = _mm_set1_epi8(static_cast<int8_t>(ctrl_t::kSentinel));
- return TrailingZeros(static_cast<uint32_t>(
- _mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl)) + 1));
+ return TrailingZeros(static_cast<uint32_t>(
+ _mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl)) + 1));
}
void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const {
auto msbs = _mm_set1_epi8(static_cast<char>(-128));
auto x126 = _mm_set1_epi8(126);
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
auto res = _mm_or_si128(_mm_shuffle_epi8(x126, ctrl), msbs);
#else
auto zero = _mm_setzero_si128();
@@ -403,7 +403,7 @@ struct GroupSse2Impl {
__m128i ctrl;
};
-#endif // ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#endif // ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
struct GroupPortableImpl {
static constexpr size_t kWidth = 8;
@@ -457,7 +457,7 @@ struct GroupPortableImpl {
uint64_t ctrl;
};
-#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
using Group = GroupSse2Impl;
#else
using Group = GroupPortableImpl;
@@ -480,23 +480,23 @@ inline bool IsValidCapacity(size_t n) { return ((n + 1) & n) == 0 && n > 0; }
// DELETED -> EMPTY
// EMPTY -> EMPTY
// FULL -> DELETED
-void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity);
+void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity);
// Rounds up the capacity to the next power of 2 minus 1, with a minimum of 1.
inline size_t NormalizeCapacity(size_t n) {
- return n ? ~size_t{} >> countl_zero(n) : 1;
+ return n ? ~size_t{} >> countl_zero(n) : 1;
}
-// General notes on capacity/growth methods below:
-// - We use 7/8th as maximum load factor. For 16-wide groups, that gives an
-// average of two empty slots per group.
-// - For (capacity+1) >= Group::kWidth, growth is 7/8*capacity.
-// - For (capacity+1) < Group::kWidth, growth == capacity. In this case, we
-// never need to probe (the whole table fits in one group) so we don't need a
-// load factor less than 1.
-
-// Given `capacity` of the table, returns the size (i.e. number of full slots)
-// at which we should grow the capacity.
+// General notes on capacity/growth methods below:
+// - We use 7/8th as maximum load factor. For 16-wide groups, that gives an
+// average of two empty slots per group.
+// - For (capacity+1) >= Group::kWidth, growth is 7/8*capacity.
+// - For (capacity+1) < Group::kWidth, growth == capacity. In this case, we
+// never need to probe (the whole table fits in one group) so we don't need a
+// load factor less than 1.
+
+// Given `capacity` of the table, returns the size (i.e. number of full slots)
+// at which we should grow the capacity.
inline size_t CapacityToGrowth(size_t capacity) {
assert(IsValidCapacity(capacity));
// `capacity*7/8`
@@ -507,7 +507,7 @@ inline size_t CapacityToGrowth(size_t capacity) {
return capacity - capacity / 8;
}
// From desired "growth" to a lowerbound of the necessary capacity.
-// Might not be a valid one and requires NormalizeCapacity().
+// Might not be a valid one and requires NormalizeCapacity().
inline size_t GrowthToLowerboundCapacity(size_t growth) {
// `growth*8/7`
if (Group::kWidth == 8 && growth == 7) {
@@ -533,78 +533,78 @@ size_t SelectBucketCountForIterRange(InputIter first, InputIter last,
return 0;
}
-inline void AssertIsFull(ctrl_t* ctrl) {
- ABSL_HARDENING_ASSERT((ctrl != nullptr && IsFull(*ctrl)) &&
- "Invalid operation on iterator. The element might have "
- "been erased, or the table might have rehashed.");
-}
-
-inline void AssertIsValid(ctrl_t* ctrl) {
- ABSL_HARDENING_ASSERT((ctrl == nullptr || IsFull(*ctrl)) &&
- "Invalid operation on iterator. The element might have "
- "been erased, or the table might have rehashed.");
-}
-
-struct FindInfo {
- size_t offset;
- size_t probe_length;
-};
-
-// The representation of the object has two modes:
-// - small: For capacities < kWidth-1
-// - large: For the rest.
-//
-// Differences:
-// - In small mode we are able to use the whole capacity. The extra control
-// bytes give us at least one "empty" control byte to stop the iteration.
-// This is important to make 1 a valid capacity.
-//
-// - In small mode only the first `capacity()` control bytes after the
+inline void AssertIsFull(ctrl_t* ctrl) {
+ ABSL_HARDENING_ASSERT((ctrl != nullptr && IsFull(*ctrl)) &&
+ "Invalid operation on iterator. The element might have "
+ "been erased, or the table might have rehashed.");
+}
+
+inline void AssertIsValid(ctrl_t* ctrl) {
+ ABSL_HARDENING_ASSERT((ctrl == nullptr || IsFull(*ctrl)) &&
+ "Invalid operation on iterator. The element might have "
+ "been erased, or the table might have rehashed.");
+}
+
+struct FindInfo {
+ size_t offset;
+ size_t probe_length;
+};
+
+// The representation of the object has two modes:
+// - small: For capacities < kWidth-1
+// - large: For the rest.
+//
+// Differences:
+// - In small mode we are able to use the whole capacity. The extra control
+// bytes give us at least one "empty" control byte to stop the iteration.
+// This is important to make 1 a valid capacity.
+//
+// - In small mode only the first `capacity()` control bytes after the
// sentinel are valid. The rest contain dummy ctrl_t::kEmpty values that do not
-// represent a real slot. This is important to take into account on
-// find_first_non_full(), where we never try ShouldInsertBackwards() for
-// small tables.
-inline bool is_small(size_t capacity) { return capacity < Group::kWidth - 1; }
-
+// represent a real slot. This is important to take into account on
+// find_first_non_full(), where we never try ShouldInsertBackwards() for
+// small tables.
+inline bool is_small(size_t capacity) { return capacity < Group::kWidth - 1; }
+
inline probe_seq<Group::kWidth> probe(const ctrl_t* ctrl, size_t hash,
- size_t capacity) {
- return probe_seq<Group::kWidth>(H1(hash, ctrl), capacity);
-}
-
-// Probes the raw_hash_set with the probe sequence for hash and returns the
-// pointer to the first empty or deleted slot.
+ size_t capacity) {
+ return probe_seq<Group::kWidth>(H1(hash, ctrl), capacity);
+}
+
+// Probes the raw_hash_set with the probe sequence for hash and returns the
+// pointer to the first empty or deleted slot.
// NOTE: this function must work with tables having both ctrl_t::kEmpty and
// ctrl_t::kDeleted in one group. Such tables appears during
// drop_deletes_without_resize.
-//
-// This function is very useful when insertions happen and:
-// - the input is already a set
-// - there are enough slots
-// - the element with the hash is not in the table
+//
+// This function is very useful when insertions happen and:
+// - the input is already a set
+// - there are enough slots
+// - the element with the hash is not in the table
template <typename = void>
inline FindInfo find_first_non_full(const ctrl_t* ctrl, size_t hash,
- size_t capacity) {
- auto seq = probe(ctrl, hash, capacity);
- while (true) {
- Group g{ctrl + seq.offset()};
- auto mask = g.MatchEmptyOrDeleted();
- if (mask) {
-#if !defined(NDEBUG)
- // We want to add entropy even when ASLR is not enabled.
- // In debug build we will randomly insert in either the front or back of
- // the group.
- // TODO(kfm,sbenza): revisit after we do unconditional mixing
- if (!is_small(capacity) && ShouldInsertBackwards(hash, ctrl)) {
- return {seq.offset(mask.HighestBitSet()), seq.index()};
- }
-#endif
- return {seq.offset(mask.LowestBitSet()), seq.index()};
- }
- seq.next();
+ size_t capacity) {
+ auto seq = probe(ctrl, hash, capacity);
+ while (true) {
+ Group g{ctrl + seq.offset()};
+ auto mask = g.MatchEmptyOrDeleted();
+ if (mask) {
+#if !defined(NDEBUG)
+ // We want to add entropy even when ASLR is not enabled.
+ // In debug build we will randomly insert in either the front or back of
+ // the group.
+ // TODO(kfm,sbenza): revisit after we do unconditional mixing
+ if (!is_small(capacity) && ShouldInsertBackwards(hash, ctrl)) {
+ return {seq.offset(mask.HighestBitSet()), seq.index()};
+ }
+#endif
+ return {seq.offset(mask.LowestBitSet()), seq.index()};
+ }
+ seq.next();
assert(seq.index() <= capacity && "full table!");
- }
-}
-
+ }
+}
+
// Extern template for inline function keep possibility of inlining.
// When compiler decided to not inline, no symbols will be added to the
// corresponding translation unit.
@@ -669,8 +669,8 @@ inline size_t AllocSize(size_t capacity, size_t slot_size, size_t slot_align) {
// if they are equal, false if they are not. If two keys compare equal, then
// their hash values as defined by Hash MUST be equal.
//
-// Allocator: an Allocator
-// [https://en.cppreference.com/w/cpp/named_req/Allocator] with which
+// Allocator: an Allocator
+// [https://en.cppreference.com/w/cpp/named_req/Allocator] with which
// the storage of the hashtable will be allocated and the elements will be
// constructed and destroyed.
template <class Policy, class Hash, class Eq, class Alloc>
@@ -769,7 +769,7 @@ class raw_hash_set {
// PRECONDITION: not an end() iterator.
reference operator*() const {
- AssertIsFull(ctrl_);
+ AssertIsFull(ctrl_);
return PolicyTraits::element(slot_);
}
@@ -778,7 +778,7 @@ class raw_hash_set {
// PRECONDITION: not an end() iterator.
iterator& operator++() {
- AssertIsFull(ctrl_);
+ AssertIsFull(ctrl_);
++ctrl_;
++slot_;
skip_empty_or_deleted();
@@ -792,8 +792,8 @@ class raw_hash_set {
}
friend bool operator==(const iterator& a, const iterator& b) {
- AssertIsValid(a.ctrl_);
- AssertIsValid(b.ctrl_);
+ AssertIsValid(a.ctrl_);
+ AssertIsValid(b.ctrl_);
return a.ctrl_ == b.ctrl_;
}
friend bool operator!=(const iterator& a, const iterator& b) {
@@ -801,10 +801,10 @@ class raw_hash_set {
}
private:
- iterator(ctrl_t* ctrl, slot_type* slot) : ctrl_(ctrl), slot_(slot) {
- // This assumption helps the compiler know that any non-end iterator is
- // not equal to any end iterator.
- ABSL_INTERNAL_ASSUME(ctrl != nullptr);
+ iterator(ctrl_t* ctrl, slot_type* slot) : ctrl_(ctrl), slot_(slot) {
+ // This assumption helps the compiler know that any non-end iterator is
+ // not equal to any end iterator.
+ ABSL_INTERNAL_ASSUME(ctrl != nullptr);
}
void skip_empty_or_deleted() {
@@ -872,8 +872,8 @@ class raw_hash_set {
explicit raw_hash_set(size_t bucket_count, const hasher& hash = hasher(),
const key_equal& eq = key_equal(),
const allocator_type& alloc = allocator_type())
- : ctrl_(EmptyGroup()),
- settings_(0, HashtablezInfoHandle(), hash, eq, alloc) {
+ : ctrl_(EmptyGroup()),
+ settings_(0, HashtablezInfoHandle(), hash, eq, alloc) {
if (bucket_count) {
capacity_ = NormalizeCapacity(bucket_count);
initialize_slots();
@@ -982,11 +982,11 @@ class raw_hash_set {
// than a full `insert`.
for (const auto& v : that) {
const size_t hash = PolicyTraits::apply(HashElement{hash_ref()}, v);
- auto target = find_first_non_full(ctrl_, hash, capacity_);
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
SetCtrl(target.offset, H2(hash), capacity_, ctrl_, slots_,
sizeof(slot_type));
emplace_at(target.offset, v);
- infoz().RecordInsert(hash, target.probe_length);
+ infoz().RecordInsert(hash, target.probe_length);
}
size_ = that.size();
growth_left() -= that.size();
@@ -1003,24 +1003,24 @@ class raw_hash_set {
// Hash, equality and allocator are copied instead of moved because
// `that` must be left valid. If Hash is std::function<Key>, moving it
// would create a nullptr functor that cannot be called.
- settings_(y_absl::exchange(that.growth_left(), 0),
- y_absl::exchange(that.infoz(), HashtablezInfoHandle()),
- that.hash_ref(), that.eq_ref(), that.alloc_ref()) {}
+ settings_(y_absl::exchange(that.growth_left(), 0),
+ y_absl::exchange(that.infoz(), HashtablezInfoHandle()),
+ that.hash_ref(), that.eq_ref(), that.alloc_ref()) {}
raw_hash_set(raw_hash_set&& that, const allocator_type& a)
: ctrl_(EmptyGroup()),
slots_(nullptr),
size_(0),
capacity_(0),
- settings_(0, HashtablezInfoHandle(), that.hash_ref(), that.eq_ref(),
- a) {
+ settings_(0, HashtablezInfoHandle(), that.hash_ref(), that.eq_ref(),
+ a) {
if (a == that.alloc_ref()) {
std::swap(ctrl_, that.ctrl_);
std::swap(slots_, that.slots_);
std::swap(size_, that.size_);
std::swap(capacity_, that.capacity_);
std::swap(growth_left(), that.growth_left());
- std::swap(infoz(), that.infoz());
+ std::swap(infoz(), that.infoz());
} else {
reserve(that.size());
// Note: this will copy elements of dense_set and unordered_set instead of
@@ -1056,12 +1056,12 @@ class raw_hash_set {
it.skip_empty_or_deleted();
return it;
}
- iterator end() { return {}; }
+ iterator end() { return {}; }
const_iterator begin() const {
return const_cast<raw_hash_set*>(this)->begin();
}
- const_iterator end() const { return {}; }
+ const_iterator end() const { return {}; }
const_iterator cbegin() const { return begin(); }
const_iterator cend() const { return end(); }
@@ -1093,7 +1093,7 @@ class raw_hash_set {
reset_growth_left();
}
assert(empty());
- infoz().RecordStorageChanged(0, capacity_);
+ infoz().RecordStorageChanged(0, capacity_);
}
// This overload kicks in when the argument is an rvalue of insertable and
@@ -1166,7 +1166,7 @@ class raw_hash_set {
template <class InputIt>
void insert(InputIt first, InputIt last) {
- for (; first != last; ++first) emplace(*first);
+ for (; first != last; ++first) emplace(*first);
}
template <class T, RequiresNotInit<T> = 0, RequiresInsertable<const T&> = 0>
@@ -1193,9 +1193,9 @@ class raw_hash_set {
}
iterator insert(const_iterator, node_type&& node) {
- auto res = insert(std::move(node));
- node = std::move(res.node);
- return res.position;
+ auto res = insert(std::move(node));
+ node = std::move(res.node);
+ return res.position;
}
// This overload kicks in if we can deduce the key from args. This enables us
@@ -1324,7 +1324,7 @@ class raw_hash_set {
// This overload is necessary because otherwise erase<K>(const K&) would be
// a better match if non-const iterator is passed as an argument.
void erase(iterator it) {
- AssertIsFull(it.ctrl_);
+ AssertIsFull(it.ctrl_);
PolicyTraits::destroy(&alloc_ref(), it.slot_);
erase_meta_only(it);
}
@@ -1358,7 +1358,7 @@ class raw_hash_set {
}
node_type extract(const_iterator position) {
- AssertIsFull(position.inner_.ctrl_);
+ AssertIsFull(position.inner_.ctrl_);
auto node =
CommonAccess::Transfer<node_type>(alloc_ref(), position.inner_.slot_);
erase_meta_only(position);
@@ -1375,8 +1375,8 @@ class raw_hash_set {
void swap(raw_hash_set& that) noexcept(
IsNoThrowSwappable<hasher>() && IsNoThrowSwappable<key_equal>() &&
- IsNoThrowSwappable<allocator_type>(
- typename AllocTraits::propagate_on_container_swap{})) {
+ IsNoThrowSwappable<allocator_type>(
+ typename AllocTraits::propagate_on_container_swap{})) {
using std::swap;
swap(ctrl_, that.ctrl_);
swap(slots_, that.slots_);
@@ -1385,16 +1385,16 @@ class raw_hash_set {
swap(growth_left(), that.growth_left());
swap(hash_ref(), that.hash_ref());
swap(eq_ref(), that.eq_ref());
- swap(infoz(), that.infoz());
- SwapAlloc(alloc_ref(), that.alloc_ref(),
- typename AllocTraits::propagate_on_container_swap{});
+ swap(infoz(), that.infoz());
+ SwapAlloc(alloc_ref(), that.alloc_ref(),
+ typename AllocTraits::propagate_on_container_swap{});
}
void rehash(size_t n) {
if (n == 0 && capacity_ == 0) return;
if (n == 0 && size_ == 0) {
destroy_slots();
- infoz().RecordStorageChanged(0, 0);
+ infoz().RecordStorageChanged(0, 0);
infoz().RecordClearedReservation();
return;
}
@@ -1412,16 +1412,16 @@ class raw_hash_set {
}
}
- void reserve(size_t n) {
+ void reserve(size_t n) {
if (n > size() + growth_left()) {
size_t m = GrowthToLowerboundCapacity(n);
- resize(NormalizeCapacity(m));
+ resize(NormalizeCapacity(m));
// This is after resize, to ensure that we have completed the allocation
// and have potentially sampled the hashtable.
infoz().RecordReservation(n);
- }
- }
+ }
+ }
// Extension API: support for heterogeneous keys.
//
@@ -1447,7 +1447,7 @@ class raw_hash_set {
(void)key;
#if defined(__GNUC__)
prefetch_heap_block();
- auto seq = probe(ctrl_, hash_ref()(key), capacity_);
+ auto seq = probe(ctrl_, hash_ref()(key), capacity_);
__builtin_prefetch(static_cast<const void*>(ctrl_ + seq.offset()));
__builtin_prefetch(static_cast<const void*>(slots_ + seq.offset()));
#endif // __GNUC__
@@ -1462,7 +1462,7 @@ class raw_hash_set {
// called heterogeneous key support.
template <class K = key_type>
iterator find(const key_arg<K>& key, size_t hash) {
- auto seq = probe(ctrl_, hash, capacity_);
+ auto seq = probe(ctrl_, hash, capacity_);
while (true) {
Group g{ctrl_ + seq.offset()};
for (int i : g.Match(H2(hash))) {
@@ -1626,7 +1626,7 @@ class raw_hash_set {
SetCtrl(index, was_never_full ? ctrl_t::kEmpty : ctrl_t::kDeleted,
capacity_, ctrl_, slots_, sizeof(slot_type));
growth_left() += was_never_full;
- infoz().RecordErase();
+ infoz().RecordErase();
}
void initialize_slots() {
@@ -1654,7 +1654,7 @@ class raw_hash_set {
mem + SlotOffset(capacity_, alignof(slot_type)));
ResetCtrl(capacity_, ctrl_, slots_, sizeof(slot_type));
reset_growth_left();
- infoz().RecordStorageChanged(size_, capacity_);
+ infoz().RecordStorageChanged(size_, capacity_);
}
void destroy_slots() {
@@ -1690,7 +1690,7 @@ class raw_hash_set {
if (IsFull(old_ctrl[i])) {
size_t hash = PolicyTraits::apply(HashElement{hash_ref()},
PolicyTraits::element(old_slots + i));
- auto target = find_first_non_full(ctrl_, hash, capacity_);
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
size_t new_i = target.offset;
total_probe_length += target.probe_length;
SetCtrl(new_i, H2(hash), capacity_, ctrl_, slots_, sizeof(slot_type));
@@ -1704,12 +1704,12 @@ class raw_hash_set {
&alloc_ref(), old_ctrl,
AllocSize(old_capacity, sizeof(slot_type), alignof(slot_type)));
}
- infoz().RecordRehash(total_probe_length);
+ infoz().RecordRehash(total_probe_length);
}
void drop_deletes_without_resize() ABSL_ATTRIBUTE_NOINLINE {
assert(IsValidCapacity(capacity_));
- assert(!is_small(capacity_));
+ assert(!is_small(capacity_));
// Algorithm:
// - mark all DELETED slots as EMPTY
// - mark all FULL slots as DELETED
@@ -1770,7 +1770,7 @@ class raw_hash_set {
}
}
reset_growth_left();
- infoz().RecordRehash(total_probe_length);
+ infoz().RecordRehash(total_probe_length);
}
void rehash_and_grow_if_necessary() {
@@ -1829,7 +1829,7 @@ class raw_hash_set {
bool has_element(const value_type& elem) const {
size_t hash = PolicyTraits::apply(HashElement{hash_ref()}, elem);
- auto seq = probe(ctrl_, hash, capacity_);
+ auto seq = probe(ctrl_, hash, capacity_);
while (true) {
Group g{ctrl_ + seq.offset()};
for (int i : g.Match(H2(hash))) {
@@ -1861,7 +1861,7 @@ class raw_hash_set {
std::pair<size_t, bool> find_or_prepare_insert(const K& key) {
prefetch_heap_block();
auto hash = hash_ref()(key);
- auto seq = probe(ctrl_, hash, capacity_);
+ auto seq = probe(ctrl_, hash, capacity_);
while (true) {
Group g{ctrl_ + seq.offset()};
for (int i : g.Match(H2(hash))) {
@@ -1878,17 +1878,17 @@ class raw_hash_set {
}
size_t prepare_insert(size_t hash) ABSL_ATTRIBUTE_NOINLINE {
- auto target = find_first_non_full(ctrl_, hash, capacity_);
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
if (ABSL_PREDICT_FALSE(growth_left() == 0 &&
!IsDeleted(ctrl_[target.offset]))) {
rehash_and_grow_if_necessary();
- target = find_first_non_full(ctrl_, hash, capacity_);
+ target = find_first_non_full(ctrl_, hash, capacity_);
}
++size_;
growth_left() -= IsEmpty(ctrl_[target.offset]);
SetCtrl(target.offset, H2(hash), capacity_, ctrl_, slots_,
sizeof(slot_type));
- infoz().RecordInsert(hash, target.probe_length);
+ infoz().RecordInsert(hash, target.probe_length);
return target.offset;
}
@@ -1931,15 +1931,15 @@ class raw_hash_set {
#endif // __GNUC__
}
- HashtablezInfoHandle& infoz() { return settings_.template get<1>(); }
+ HashtablezInfoHandle& infoz() { return settings_.template get<1>(); }
- hasher& hash_ref() { return settings_.template get<2>(); }
- const hasher& hash_ref() const { return settings_.template get<2>(); }
- key_equal& eq_ref() { return settings_.template get<3>(); }
- const key_equal& eq_ref() const { return settings_.template get<3>(); }
- allocator_type& alloc_ref() { return settings_.template get<4>(); }
+ hasher& hash_ref() { return settings_.template get<2>(); }
+ const hasher& hash_ref() const { return settings_.template get<2>(); }
+ key_equal& eq_ref() { return settings_.template get<3>(); }
+ const key_equal& eq_ref() const { return settings_.template get<3>(); }
+ allocator_type& alloc_ref() { return settings_.template get<4>(); }
const allocator_type& alloc_ref() const {
- return settings_.template get<4>();
+ return settings_.template get<4>();
}
// TODO(alkis): Investigate removing some of these fields:
@@ -1949,11 +1949,11 @@ class raw_hash_set {
slot_type* slots_ = nullptr; // [capacity * slot_type]
size_t size_ = 0; // number of full slots
size_t capacity_ = 0; // total number of slots
- y_absl::container_internal::CompressedTuple<size_t /* growth_left */,
- HashtablezInfoHandle, hasher,
+ y_absl::container_internal::CompressedTuple<size_t /* growth_left */,
+ HashtablezInfoHandle, hasher,
key_equal, allocator_type>
- settings_{0, HashtablezInfoHandle{}, hasher{}, key_equal{},
- allocator_type{}};
+ settings_{0, HashtablezInfoHandle{}, hasher{}, key_equal{},
+ allocator_type{}};
};
// Erases all elements that satisfy the predicate `pred` from the container `c`.
@@ -1978,7 +1978,7 @@ struct HashtableDebugAccess<Set, y_absl::void_t<typename Set::raw_hash_set>> {
const typename Set::key_type& key) {
size_t num_probes = 0;
size_t hash = set.hash_ref()(key);
- auto seq = probe(set.ctrl_, hash, set.capacity_);
+ auto seq = probe(set.ctrl_, hash, set.capacity_);
while (true) {
container_internal::Group g{set.ctrl_ + seq.offset()};
for (int i : g.Match(container_internal::H2(hash))) {
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make
index d636929b87..8091b96b3c 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make
@@ -2,13 +2,13 @@
LIBRARY()
-WITHOUT_LICENSE_TEXTS()
-
-OWNER(
- somov
- g:cpp-contrib
-)
+WITHOUT_LICENSE_TEXTS()
+OWNER(
+ somov
+ g:cpp-contrib
+)
+
LICENSE(Apache-2.0)
PEERDIR(
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h
index f55d6293ae..8d75094512 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h
@@ -16,7 +16,7 @@
#define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_CONSTRUCTOR_TEST_H_
#include <algorithm>
-#include <unordered_map>
+#include <unordered_map>
#include <vector>
#include "gmock/gmock.h"
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h
index 725cfdc345..fd4e3977a2 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h
@@ -319,8 +319,8 @@ class UniquePtrModifiersTest : public ::testing::Test {
}
};
-GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(UniquePtrModifiersTest);
-
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(UniquePtrModifiersTest);
+
TYPED_TEST_SUITE_P(UniquePtrModifiersTest);
// Test that we do not move from rvalue arguments if an insertion does not
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h
index 07e26def79..f3cdce8f22 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h
@@ -225,8 +225,8 @@ class node_hash_map
//
// size_type erase(const key_type& key):
//
- // Erases the element with the matching key, if it exists, returning the
- // number of elements erased (0 or 1).
+ // Erases the element with the matching key, if it exists, returning the
+ // number of elements erased (0 or 1).
using Base::erase;
// node_hash_map::insert()
@@ -375,11 +375,11 @@ class node_hash_map
// key value and returns a node handle owning that extracted data. If the
// `node_hash_map` does not contain an element with a matching key, this
// function returns an empty node handle.
- //
- // NOTE: when compiled in an earlier version of C++ than C++17,
- // `node_type::key()` returns a const reference to the key instead of a
- // mutable reference. We cannot safely return a mutable reference without
- // std::launder (which is not available before C++17).
+ //
+ // NOTE: when compiled in an earlier version of C++ than C++17,
+ // `node_type::key()` returns a const reference to the key instead of a
+ // mutable reference. We cannot safely return a mutable reference without
+ // std::launder (which is not available before C++17).
using Base::extract;
// node_hash_map::merge()
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h
index aa98bb29b8..bd8fe21a70 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h
@@ -18,7 +18,7 @@
//
// An `y_absl::node_hash_set<T>` is an unordered associative container designed to
// be a more efficient replacement for `std::unordered_set`. Like
-// `unordered_set`, search, insertion, and deletion of set elements can be done
+// `unordered_set`, search, insertion, and deletion of set elements can be done
// as an `O(1)` operation. However, `node_hash_set` (and other unordered
// associative containers known as the collection of Abseil "Swiss tables")
// contain other optimizations that result in both memory and computation
@@ -60,7 +60,7 @@ struct NodeHashSetPolicy;
// following notable differences:
//
// * Supports heterogeneous lookup, through `find()`, `operator[]()` and
-// `insert()`, provided that the set is provided a compatible heterogeneous
+// `insert()`, provided that the set is provided a compatible heterogeneous
// hashing function and equality operator.
// * Contains a `capacity()` member function indicating the number of element
// slots (open, deleted, and empty) within the hash set.
@@ -76,13 +76,13 @@ struct NodeHashSetPolicy;
// Example:
//
// // Create a node hash set of three strings
-// y_absl::node_hash_set<TString> ducks =
+// y_absl::node_hash_set<TString> ducks =
// {"huey", "dewey", "louie"};
//
-// // Insert a new element into the node hash set
-// ducks.insert("donald");
+// // Insert a new element into the node hash set
+// ducks.insert("donald");
//
-// // Force a rehash of the node hash set
+// // Force a rehash of the node hash set
// ducks.rehash(0);
//
// // See if "dewey" is present
@@ -100,7 +100,7 @@ class node_hash_set
public:
// Constructors and Assignment Operators
//
- // A node_hash_set supports the same overload set as `std::unordered_set`
+ // A node_hash_set supports the same overload set as `std::unordered_set`
// for construction and assignment:
//
// * Default constructor
@@ -167,7 +167,7 @@ class node_hash_set
// available within the `node_hash_set`.
//
// NOTE: this member function is particular to `y_absl::node_hash_set` and is
- // not provided in the `std::unordered_set` API.
+ // not provided in the `std::unordered_set` API.
using Base::capacity;
// node_hash_set::empty()
@@ -208,7 +208,7 @@ class node_hash_set
// `void`.
//
// NOTE: this return behavior is different than that of STL containers in
- // general and `std::unordered_set` in particular.
+ // general and `std::unordered_set` in particular.
//
// iterator erase(const_iterator first, const_iterator last):
//
@@ -217,8 +217,8 @@ class node_hash_set
//
// size_type erase(const key_type& key):
//
- // Erases the element with the matching key, if it exists, returning the
- // number of elements erased (0 or 1).
+ // Erases the element with the matching key, if it exists, returning the
+ // number of elements erased (0 or 1).
using Base::erase;
// node_hash_set::insert()
@@ -314,7 +314,7 @@ class node_hash_set
// node_hash_set::merge()
//
- // Extracts elements from a given `source` node hash set into this
+ // Extracts elements from a given `source` node hash set into this
// `node_hash_set`. If the destination `node_hash_set` already contains an
// element with an equivalent key, that element is not extracted.
using Base::merge;
@@ -322,15 +322,15 @@ class node_hash_set
// node_hash_set::swap(node_hash_set& other)
//
// Exchanges the contents of this `node_hash_set` with those of the `other`
- // node hash set, avoiding invocation of any move, copy, or swap operations on
+ // node hash set, avoiding invocation of any move, copy, or swap operations on
// individual elements.
//
// All iterators and references on the `node_hash_set` remain valid, excepting
// for the past-the-end iterator, which is invalidated.
//
- // `swap()` requires that the node hash set's hashing and key equivalence
+ // `swap()` requires that the node hash set's hashing and key equivalence
// functions be Swappable, and are exchaged using unqualified calls to
- // non-member `swap()`. If the set's allocator has
+ // non-member `swap()`. If the set's allocator has
// `std::allocator_traits<allocator_type>::propagate_on_container_swap::value`
// set to `true`, the allocators are also exchanged using an unqualified call
// to non-member `swap()`; otherwise, the allocators are not swapped.
@@ -385,14 +385,14 @@ class node_hash_set
// node_hash_set::bucket_count()
//
// Returns the number of "buckets" within the `node_hash_set`. Note that
- // because a node hash set contains all elements within its internal storage,
+ // because a node hash set contains all elements within its internal storage,
// this value simply equals the current capacity of the `node_hash_set`.
using Base::bucket_count;
// node_hash_set::load_factor()
//
// Returns the current load factor of the `node_hash_set` (the average number
- // of slots occupied with a value within the hash set).
+ // of slots occupied with a value within the hash set).
using Base::load_factor;
// node_hash_set::max_load_factor()
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make
index b5ead45856..9a44988749 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make
@@ -1,14 +1,14 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-OWNER(
- somov
- g:cpp-contrib
-)
-
-LICENSE(Apache-2.0)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-END()
+# Generated by devtools/yamaker.
+
+LIBRARY()
+
+OWNER(
+ somov
+ g:cpp-contrib
+)
+
+LICENSE(Apache-2.0)
+
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+
+END()