34#ifndef PHMAP_BTREE_BTREE_CONTAINER_H_
35#define PHMAP_BTREE_BTREE_CONTAINER_H_
40 #pragma warning(disable : 4127)
41 #pragma warning(disable : 4324)
42 #pragma warning(disable : 4355)
43 #pragma warning(disable : 4365)
44 #pragma warning(disable : 4514)
45 #pragma warning(disable : 4623)
46 #pragma warning(disable : 4625)
47 #pragma warning(disable : 4626)
48 #pragma warning(disable : 4710)
49 #pragma warning(disable : 4711)
50 #pragma warning(disable : 4820)
51 #pragma warning(disable : 4868)
52 #pragma warning(disable : 5026)
53 #pragma warning(disable : 5027)
54 #pragma warning(disable : 5045)
67#if PHMAP_HAVE_STD_STRING_VIEW
68 #include <string_view>
73#if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__)
74 #define PHMAP_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1
87 namespace type_traits_internal {
90#if defined(_MSC_VER) && !defined(__GNUC__)
92 #pragma warning(disable : 4624)
101#if defined(_MSC_VER) && !defined(__GNUC__)
107 : std::integral_constant<
108 bool, std::is_move_constructible<
109 type_traits_internal::SingleMemberUnion<T>>::value &&
110 phmap::is_trivially_destructible<T>::value> {};
114 : std::integral_constant<
115 bool, std::is_copy_constructible<
116 type_traits_internal::SingleMemberUnion<T>>::value &&
117 phmap::is_trivially_destructible<T>::value> {};
133 template <
typename... Ts>
137 template <
typename T>
139 : std::integral_constant<
140 bool, !(std::is_reference<T>::value ||
141 std::is_const<typename std::add_const<T>::type>::value)> {};
144 namespace type_traits_internal {
146 template <
typename T>
150 std::is_copy_constructible<ExtentsRemoved>::value ||
151 std::is_move_constructible<ExtentsRemoved>::value;
164 !std::is_reference<ExtentsRemoved>::value;
167 template <
typename T>
169 : std::integral_constant<
170 bool, type_traits_internal::is_trivially_copyable_impl<T>::kValue> {};
173 namespace swap_internal {
187 class IsNoexcept = std::integral_constant<
188 bool,
noexcept(
swap(std::declval<T&>(), std::declval<T&>()))>>
199 template <class T, phmap::enable_if_t<IsSwappable<T>::value,
int> = 0>
208 namespace type_traits_internal {
218 namespace compare_internal {
222 template <
typename T>
224 static_assert(
sizeof(T) < 0,
"Only literal `0` is allowed.");
227 template <
typename NullPtrT = std::
nullptr_t>
233 typename =
typename std::enable_if<
234 std::is_same<T, std::nullptr_t>::value ||
235 (std::is_integral<T>::value && !std::is_same<T, int>::value)>::type,
251#if defined(__cpp_inline_variables) && !defined(_MSC_VER)
253#define PHMAP_COMPARE_INLINE_BASECLASS_DECL(name)
255#define PHMAP_COMPARE_INLINE_SUBCLASS_DECL(type, name) \
256 static const type name;
258#define PHMAP_COMPARE_INLINE_INIT(type, name, init) \
259 inline constexpr type type::name(init)
263#define PHMAP_COMPARE_INLINE_BASECLASS_DECL(name) \
266#define PHMAP_COMPARE_INLINE_SUBCLASS_DECL(type, name)
268#define PHMAP_COMPARE_INLINE_INIT(type, name, init) \
269 template <typename T> \
270 const T compare_internal::type##_base<T>::name(init)
277 template <
typename T>
283 template <
typename T>
291 template <
typename T>
299 template <
typename T>
306 template <
typename T>
327 friend constexpr
bool operator==(
328 weak_equality v, compare_internal::OnlyLiteralZero<>) noexcept {
329 return v.value_ == 0;
333 return v.value_ != 0;
337 return 0 == v.value_;
341 return 0 != v.value_;
366 return value_ == 0 ? weak_equality::equivalent
367 : weak_equality::nonequivalent;
372 return v.value_ == 0;
376 return v.value_ != 0;
380 return 0 == v.value_;
384 return 0 != v.value_;
422 return value_ == 0 ? weak_equality::equivalent
423 : weak_equality::nonequivalent;
428 return v.is_ordered() && v.value_ == 0;
432 return !v.is_ordered() || v.value_ != 0;
436 return v.is_ordered() && v.value_ < 0;
440 return v.is_ordered() && v.value_ <= 0;
444 return v.is_ordered() && v.value_ > 0;
448 return v.is_ordered() && v.value_ >= 0;
452 return v.is_ordered() && 0 == v.value_;
456 return !v.is_ordered() || 0 != v.value_;
460 return v.is_ordered() && 0 < v.value_;
464 return v.is_ordered() && 0 <= v.value_;
468 return v.is_ordered() && 0 > v.value_;
472 return v.is_ordered() && 0 >= v.value_;
502 return value_ == 0 ? weak_equality::equivalent
503 : weak_equality::nonequivalent;
506 return value_ == 0 ? partial_ordering::equivalent
507 : (
value_ < 0 ? partial_ordering::less
508 : partial_ordering::greater);
513 return v.value_ == 0;
517 return v.value_ != 0;
525 return v.value_ <= 0;
533 return v.value_ >= 0;
537 return 0 == v.value_;
541 return 0 != v.value_;
549 return 0 <= v.value_;
557 return 0 >= v.value_;
586 return value_ == 0 ? weak_equality::equivalent
587 : weak_equality::nonequivalent;
590 return value_ == 0 ? strong_equality::equal : strong_equality::nonequal;
593 return value_ == 0 ? partial_ordering::equivalent
594 : (
value_ < 0 ? partial_ordering::less
595 : partial_ordering::greater);
599 ? weak_ordering::equivalent
600 : (
value_ < 0 ? weak_ordering::less : weak_ordering::greater);
605 return v.value_ == 0;
609 return v.value_ != 0;
617 return v.value_ <= 0;
625 return v.value_ >= 0;
629 return 0 == v.value_;
633 return 0 != v.value_;
641 return 0 <= v.value_;
649 return 0 >= v.value_;
662#undef PHMAP_COMPARE_INLINE_BASECLASS_DECL
663#undef PHMAP_COMPARE_INLINE_SUBCLASS_DECL
664#undef PHMAP_COMPARE_INLINE_INIT
666 namespace compare_internal {
672 template <
typename BoolType,
679 template <
typename Compare,
typename K,
typename LK>
688 template <
typename Int,
691 return c < 0 ? phmap::weak_ordering::less
692 : c == 0 ? phmap::weak_ordering::equivalent
693 : phmap::weak_ordering::greater;
701 typename Compare,
typename K,
typename LK,
703 Compare,
const K &,
const LK &>>::value,
706 const K &x,
const LK &y) {
710 typename Compare,
typename K,
typename LK,
712 const K &,
const LK &>>::value,
715 const K &x,
const LK &y) {
716 return compare(x, y) ? phmap::weak_ordering::less
717 : compare(y, x) ? phmap::weak_ordering::greater
718 : phmap::weak_ordering::equivalent;
731 template <
typename Compare,
typename T>
733 std::is_convertible<phmap::invoke_result_t<Compare, const T &, const T &>,
743#if PHMAP_HAVE_STD_STRING_VIEW
748 std::string_view rhs)
const {
753 std::string rhs)
const {
765#if PHMAP_HAVE_STD_STRING_VIEW
769 std::string_view rhs)
const {
774 std::string rhs)
const {
791 template <
typename Compare>
811#if PHMAP_HAVE_STD_STRING_VIEW
818 struct key_compare_to_adapter<
phmap::
Less<std::string_view>> {
819 using type = StringBtreeDefaultLess;
823 struct key_compare_to_adapter<
std::greater<std::string_view>> {
824 using type = StringBtreeDefaultGreater;
828 template <
typename Key,
typename Compare,
typename Alloc,
int TargetNodeSize,
829 bool Multi,
typename SlotPolicy>
849 using init_type =
typename slot_policy::mutable_value_type;
862 TargetNodeSize - (
sizeof(
void *) + 4),
869 (std::numeric_limits<uint8_t>::max)()),
875 return slot_policy::element(slot);
878 return slot_policy::element(slot);
880 template <
class... Args>
882 slot_policy::construct(alloc, slot, std::forward<Args>(args)...);
885 slot_policy::construct(alloc, slot, other);
888 slot_policy::destroy(alloc, slot);
895 slot_policy::swap(alloc, a, b);
898 slot_policy::move(alloc, src, dest);
902 slot_policy::move(alloc, first, last, result);
908 template <
typename Key,
typename Data,
typename Compare,
typename Alloc,
909 int TargetNodeSize,
bool Multi>
911 phmap::priv::map_slot_policy<Key, Data>> {
927 template <
typename T,
typename U>
929 ->
decltype(std::declval<key_compare>()(left.first, right.first)) {
930 return key_compare::operator()(left.first, right.first);
937 static const Key &
key(
const slot_type *x) {
return slot_policy::key(x); }
943 template <
typename Key>
952 template <
typename Alloc,
class... Args>
955 std::forward<Args>(args)...);
958 template <
typename Alloc>
963 template <
typename Alloc>
968 template <
typename Alloc>
974 template <
typename Alloc>
976 *dest = std::move(*src);
979 template <
typename Alloc>
982 for (
slot_type *src = first, *dest = result; src != last; ++src, ++dest)
983 move(alloc, src, dest);
989 template <
typename Key,
typename Compare,
typename Alloc,
int TargetNodeSize,
992 set_slot_policy<Key>> {
994 using slot_type =
typename set_params::common_params::slot_type;
1006 template <
typename Compare>
1009 template <
typename K,
typename LK>
1021 template <
typename V,
bool IsCompareTo>
1033 template <
typename V>
1038 static constexpr bool IsEq() {
return false; }
1044 template <
typename Params>
1071 std::is_arithmetic<key_type>::value &&
1084 "Alignment of all nodes must be equal.");
1109 return begin == end ? begin
1111 params_type::kTargetNodeSize
1127 kInternalNodeMaxCount = 0,
1152 template <
size_type N>
1153 inline typename layout_type::template ElementType<N> *
GetField() {
1155 assert(N < 3 || !
leaf());
1156 return InternalLayout().template Pointer<N>(
reinterpret_cast<char *
>(
this));
1159 template <
size_type N>
1160 inline const typename layout_type::template ElementType<N> *
GetField()
const {
1161 assert(N < 3 || !
leaf());
1163 reinterpret_cast<const char *
>(
this));
1178 bool leaf()
const {
return GetField<1>()[3] != kInternalNodeMaxCount; }
1192 return max_cnt ==
field_type{kInternalNodeMaxCount}
1213#if defined(__GNUC__) || defined(__clang__)
1214#pragma GCC diagnostic push
1215#pragma GCC diagnostic ignored "-Warray-bounds"
1228#if defined(__GNUC__) || defined(__clang__)
1229#pragma GCC diagnostic pop
1237 template <
typename K>
1244 template <
typename K>
1247 return use_linear_search::value ?
linear_search(k, upper_compare).value
1251 template <
typename K,
typename Compare>
1258 template <
typename K,
typename Compare>
1267 template <
typename K,
typename Compare>
1269 const K &k,
int s,
const int e,
const Compare &comp,
1270 std::false_type )
const {
1272 if (!comp(
key(s), k)) {
1282 template <
typename K,
typename Compare>
1284 const K &k,
int s,
const int e,
const Compare &comp,
1285 std::true_type )
const {
1300 template <
typename K,
typename Compare>
1302 const K &k,
int s,
int e,
const Compare &comp,
1303 std::false_type )
const {
1305 const int mid = (s + e) >> 1;
1306 if (comp(
key(mid), k)) {
1317 template <
typename K,
typename CompareTo>
1319 const K &k,
int s,
int e,
const CompareTo &comp,
1320 std::true_type )
const {
1321 if (is_multi_container::value) {
1324 const int mid = (s + e) >> 1;
1338 return {s, exact_match};
1341 const int mid = (s + e) >> 1;
1357 template <
typename... Args>
1407 for (
int i = 0; i <
count(); ++i) {
1415 return use_linear_search::value;
1419 template <
typename... Args>
1422 params_type::construct(alloc,
slot(i), std::forward<Args>(args)...);
1425 params_type::destroy(alloc,
slot(i));
1437 src != end; ++src, ++dest) {
1438 params_type::construct(alloc, dest, src);
1450 template <
typename P>
1452 template <
typename N,
typename R,
typename P>
1457 template <
typename Node,
typename Reference,
typename Po
inter>
1493 template <
typename N,
typename R,
typename P,
1495 std::is_same<btree_iterator<N, R, P>,
iterator>::value &&
1496 std::is_same<btree_iterator, const_iterator>::value,
1506 template <
typename N,
typename R,
typename P,
1509 std::is_same<btree_iterator, iterator>::value,
1516 if (
node->leaf() && ++position < node->count()) {
1573 template <
typename Params>
1575 template <
typename Tree>
1577 template <
typename Tree>
1579 template <
typename Tree>
1581 template <
typename Tree>
1583 template <
typename N,
typename R,
typename P>
1585 template <
typename TreeType,
typename CheckerType>
1598 template <
typename Params>
1627 assert(empty_node.
parent == &empty_node);
1690 template <
typename Btree>
1701 :
root_(std::move(x.root_)),
1742 template <
typename K>
1746 template <
typename K>
1752 template <
typename K>
1756 template <
typename K>
1764 template <
typename K>
1768 template <
typename K>
1769 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const {
1777 template <
typename... Args>
1786 template <
typename... Args>
1792 template <
typename InputIterator>
1796 template <
typename ValueType>
1800 template <
typename ValueType>
1802 return insert_multi(params_type::key(v), std::forward<ValueType>(v));
1809 template <
typename ValueType>
1813 template <
typename InputIterator>
1828 template <
typename K>
1833 template <
typename K>
1838 template <
typename K>
1842 template <
typename K>
1848 template <
typename K>
1851 if (beg.
node ==
nullptr) {
1858 template <
typename K>
1861 return std::distance(range.first, range.second);
1871 return root_.template get<0>();
1873 template <
typename K,
typename LK>
1900 }
while (n !=
root());
1921 return sizeof(*this) +
1924 return sizeof(*this) +
1944 if (
empty())
return 0.0;
1952 if (
empty())
return 0.0;
1954 static_cast<double>(
size());
1975 return &
root_.template get<1>();
1978 return root_.template get<1>();
1985 phmap::priv::Allocate<node_type::Alignment()>(
2010 phmap::priv::Deallocate<node_type::Alignment()>(
2040 return iter.
node !=
nullptr ? iter :
end();
2043 return iter.node !=
nullptr ? iter :
end();
2048 template <
typename... Args>
2056 template <
typename IterType>
2067 template <
typename K>
2069 const K &key)
const;
2071 template <
typename K>
2073 const K &key, std::false_type )
const;
2075 template <
typename K>
2077 const K &key, std::true_type )
const;
2080 template <
typename K>
2084 template <
typename K>
2088 template <
typename K>
2100 if (node ==
nullptr || (node ==
root() &&
empty())) {
2107 for (
int i = 0; i <= node->
count(); ++i) {
2136 template <
typename P>
2137 template <
typename... Args>
2141 assert(i <= count());
2145 value_init(count(), alloc, slot(count() - 1));
2146 for (
size_type j = count() - 1; j > i; --j)
2147 params_type::move(alloc, slot(j - 1), slot(j));
2148 value_destroy(i, alloc);
2150 value_init(i, alloc, std::forward<Args>(args)...);
2153 if (!leaf() && count() > i + 1) {
2154 for (
int j = count(); j > (int)(i + 1); --j) {
2155 set_child(j, child(j - 1));
2161 template <
typename P>
2163 if (!leaf() && count() > i + 1) {
2164 assert(child(i + 1)->count() == 0);
2165 for (
size_type j = i + 1; j < count(); ++j) {
2166 set_child(j, child(j + 1));
2168 clear_child(count());
2171 remove_values_ignore_children(i, 1, alloc);
2174 template <
typename P>
2177 params_type::move(alloc, slot(i + to_erase), slot(count()), slot(i));
2178 value_destroy_n(count() - to_erase, to_erase, alloc);
2182 template <
typename P>
2186 assert(parent() == right->
parent());
2187 assert(position() + 1 == right->
position());
2188 assert(right->
count() >= count());
2189 assert(to_move >= 1);
2190 assert(to_move <= right->count());
2193 value_init(count(), alloc, parent()->slot(position()));
2199 params_type::move(alloc, right->
slot(to_move - 1),
2200 parent()->slot(position()));
2203 params_type::move(alloc, right->
slot(to_move), right->
slot(right->
count()),
2211 for (
int i = 0; i < to_move; ++i) {
2212 init_child(count() + i + 1, right->
child(i));
2214 for (
int i = 0; i <= right->
count() - to_move; ++i) {
2215 assert(i + to_move <= right->max_count());
2226 template <
typename P>
2230 assert(parent() == right->
parent());
2231 assert(position() + 1 == right->
position());
2232 assert(count() >= right->
count());
2233 assert(to_move >= 1);
2234 assert(to_move <= count());
2242 if (right->
count() >= to_move) {
2248 right->
count(), right, alloc);
2249 if (right->
count() > to_move) {
2251 *dest = right->
slot(right->
count() - 1),
2252 *end = right->
slot(0);
2253 src >= end; --src, --dest) {
2254 params_type::move(alloc, src, dest);
2259 params_type::move(alloc, parent()->slot(position()),
2260 right->
slot(to_move - 1));
2263 params_type::move(alloc, slot(count() - (to_move - 1)), slot(count()),
2273 right->
value_init(to_move - 1, alloc, parent()->slot(position()));
2276 const size_type uninitialized_remaining = to_move - right->
count() - 1;
2277 uninitialized_move_n(uninitialized_remaining,
2278 count() - uninitialized_remaining, right->
count(),
2280 params_type::move(alloc, slot(count() - (to_move - 1)),
2281 slot(count() - uninitialized_remaining), right->
slot(0));
2285 params_type::move(alloc, slot(count() - to_move), parent()->slot(position()));
2288 value_destroy_n(count() - to_move, to_move, alloc);
2292 for (
int i = right->
count(); i >= 0; --i) {
2296 for (
int i = 1; i <= to_move; ++i) {
2297 right->
init_child(i - 1, child(count() - to_move + i));
2298 clear_child(count() - to_move + i);
2307 template <
typename P>
2310 assert(dest->
count() == 0);
2311 assert(max_count() == kNodeValues);
2317 if (insert_position == 0) {
2319 }
else if (insert_position == kNodeValues) {
2325 assert(count() >= 1);
2328 uninitialized_move_n(dest->
count(), count(), 0, dest, alloc);
2331 value_destroy_n(count(), dest->
count(), alloc);
2335 parent()->emplace_value(position(), alloc, slot(count()));
2336 value_destroy(count(), alloc);
2337 parent()->init_child(position() + 1, dest);
2340 for (
int i = 0; i <= dest->
count(); ++i) {
2341 assert(child(count() + i + 1) !=
nullptr);
2343 clear_child(count() + i + 1);
2348 template <
typename P>
2350 assert(parent() == src->
parent());
2351 assert(position() + 1 == src->
position());
2354 value_init(count(), alloc, parent()->slot(position()));
2364 for (
int i = 0; i <= src->
count(); ++i) {
2365 init_child(count() + i + 1, src->
child(i));
2375 parent()->remove_value(position(), alloc);
2378 template <
typename P>
2381 assert(leaf() == x->
leaf());
2385 if (smaller->
count() > larger->count()) {
2386 swap(smaller, larger);
2391 *end = a + smaller->
count();
2392 a != end; ++a, ++b) {
2393 params_type::swap(alloc, a, b);
2398 larger->uninitialized_move_n(to_move, smaller->
count(), smaller->
count(),
2400 larger->value_destroy_n(smaller->
count(), to_move, alloc);
2409 for (; i <= smaller->
count(); ++i) {
2411 larger->child(i)->set_parent(larger);
2414 for (; i <= larger->count(); ++i) {
2416 larger->clear_child(i);
2426 template <
typename N,
typename R,
typename P>
2429 assert(position >= node->count());
2431 while (position == node->count() && !node->is_root()) {
2432 assert(node->parent()->child(node->position()) == node);
2433 position = node->position();
2434 node = node->parent();
2436 if (position == node->count()) {
2440 assert(position < node->count());
2441 node = node->child(position + 1);
2442 while (!node->leaf()) {
2443 node = node->child(0);
2449 template <
typename N,
typename R,
typename P>
2452 assert(position <= -1);
2454 while (position < 0 && !node->is_root()) {
2455 assert(node->parent()->child(node->position()) == node);
2456 position = node->position() - 1;
2457 node = node->parent();
2463 assert(position >= 0);
2464 node = node->child(position);
2465 while (!node->leaf()) {
2466 node = node->child(node->count());
2468 position = node->count() - 1;
2474 template <
typename P>
2475 template <
typename Btree>
2477 static_assert(std::is_same<btree, Btree>::value ||
2478 std::is_same<const btree, Btree>::value,
2479 "Btree type must be same or const.");
2484 auto iter = x->begin();
2485 if (iter == x->end())
return;
2486 insert_multi(maybe_move_from_iterator(iter));
2488 for (; iter != x->end(); ++iter) {
2491 internal_emplace(end(), maybe_move_from_iterator(iter));
2495 template <
typename P>
2497 static_assert(std::is_nothrow_copy_constructible<key_compare>::value,
2498 "Key comparison must be nothrow copy constructible");
2499 static_assert(std::is_nothrow_copy_constructible<allocator_type>::value,
2500 "Allocator must be nothrow copy constructible");
2502 "iterator not trivially copyable.");
2508 "target node size too large");
2511 using compare_result_type =
2514 std::is_same<compare_result_type, bool>::value ||
2515 std::is_convertible<compare_result_type, phmap::weak_ordering>::value,
2516 "key comparison function must return phmap::{weak,strong}_ordering or "
2520 static_assert(node_type::MinimumOverhead() >=
sizeof(
void *) + 4,
2521 "node space assumption incorrect");
2526 template <
typename P>
2528 : root_(comp, alloc, EmptyNode()), rightmost_(EmptyNode()), size_(0) {}
2530 template <
typename P>
2535 template <
typename P>
2536 template <
typename... Args>
2538 -> std::pair<iterator, bool> {
2540 mutable_root() = rightmost_ = new_leaf_root_node(1);
2543 auto res = internal_locate(key);
2546 if (res.HasMatch()) {
2549 return {iter,
false};
2552 iterator last = internal_last(iter);
2553 if (last.
node && !compare_keys(key, last.
key())) {
2555 return {last,
false};
2558 return {internal_emplace(iter, std::forward<Args>(args)...),
true};
2561 template <
typename P>
2562 template <
typename... Args>
2565 -> std::pair<iterator, bool> {
2567 if (position == end() || compare_keys(key, position.key())) {
2569 if (position == begin() || compare_keys((--prev).key(), key)) {
2571 return {internal_emplace(position, std::forward<Args>(args)...),
true};
2573 }
else if (compare_keys(position.key(), key)) {
2575 if (position == end() || compare_keys(key, position.key())) {
2577 return {internal_emplace(position, std::forward<Args>(args)...),
true};
2581 return {position,
false};
2584 return insert_unique(key, std::forward<Args>(args)...);
2587 template <
typename P>
2588 template <
typename InputIterator>
2590 for (; b != e; ++b) {
2591 insert_hint_unique(end(), params_type::key(*b), *b);
2595 template <
typename P>
2596 template <
typename ValueType>
2599 mutable_root() = rightmost_ = new_leaf_root_node(1);
2602 iterator iter = internal_upper_bound(key);
2603 if (iter.
node ==
nullptr) {
2606 return internal_emplace(iter, std::forward<ValueType>(v));
2609 template <
typename P>
2610 template <
typename ValueType>
2613 const key_type &key = params_type::key(v);
2614 if (position == end() || !compare_keys(position.key(), key)) {
2616 if (position == begin() || !compare_keys(key, (--prev).key())) {
2618 return internal_emplace(position, std::forward<ValueType>(v));
2623 if (next == end() || !compare_keys(next.
key(), key)) {
2625 return internal_emplace(next, std::forward<ValueType>(v));
2629 return insert_multi(std::forward<ValueType>(v));
2632 template <
typename P>
2633 template <
typename InputIterator>
2635 for (; b != e; ++b) {
2636 insert_hint_multi(end(), *b);
2640 template <
typename P>
2645 *mutable_key_comp() = x.key_comp();
2647 allocator_type>::propagate_on_container_copy_assignment::value) {
2648 *mutable_allocator() = x.allocator();
2651 copy_or_move_values_in_order(&x);
2656 template <
typename P>
2663 allocator_type>::propagate_on_container_copy_assignment::value) {
2665 swap(root_, x.root_);
2666 swap(rightmost_, x.rightmost_);
2667 swap(size_, x.size_);
2669 if (allocator() == x.allocator()) {
2670 swap(mutable_root(), x.mutable_root());
2671 swap(*mutable_key_comp(), *x.mutable_key_comp());
2672 swap(rightmost_, x.rightmost_);
2673 swap(size_, x.size_);
2679 *mutable_key_comp() = x.key_comp();
2680 copy_or_move_values_in_order(&x);
2687 template <
typename P>
2689 bool internal_delete =
false;
2690 if (!iter.node->leaf()) {
2697 assert(iter.node->leaf());
2698 params_type::move(mutable_allocator(), iter.node->slot(iter.position),
2700 internal_delete =
true;
2704 iter.node->remove_value(iter.position, mutable_allocator());
2714 iterator res = rebalance_after_delete(iter);
2717 if (internal_delete) {
2723 template <
typename P>
2727 bool first_iteration =
true;
2729 if (iter.node == root()) {
2736 if (iter.node->count() >= kMinNodeValues) {
2739 bool merged = try_merge_or_rebalance(&iter);
2742 if (first_iteration) {
2744 first_iteration =
false;
2749 iter.
position = iter.node->position();
2750 iter.node = iter.node->parent();
2763 template <
typename P>
2765 -> std::pair<size_type, iterator> {
2775 return {count, this->end()};
2778 if (_begin.node == _end.node) {
2779 erase_same_node(_begin, _end);
2781 return {count, rebalance_after_delete(_begin)};
2784 const size_type target_size = size_ - count;
2785 while (size_ > target_size) {
2786 if (_begin.node->leaf()) {
2787 const size_type remaining_to_erase = size_ - target_size;
2788 const size_type remaining_in_node = _begin.node->count() - _begin.position;
2789 _begin = erase_from_leaf_node(
2790 _begin, (std::min)(remaining_to_erase, remaining_in_node));
2792 _begin = erase(_begin);
2795 return {count, _begin};
2798 template <
typename P>
2805 if (!node->
leaf()) {
2807 for (
size_type i = 0; i < to_erase; ++i) {
2817 mutable_allocator());
2826 template <
typename P>
2830 assert(node->
leaf());
2831 assert(node->
count() > _begin.position);
2832 assert(_begin.position + to_erase <= node->count());
2835 mutable_allocator());
2839 return rebalance_after_delete(_begin);
2842 template <
typename P>
2843 template <
typename K>
2845 const iterator iter = internal_find(key);
2846 if (iter.
node ==
nullptr) {
2854 template <
typename P>
2855 template <
typename K>
2857 const iterator _begin = internal_lower_bound(key);
2858 if (_begin.
node ==
nullptr) {
2863 const iterator _end = internal_end(internal_upper_bound(key));
2864 return erase(_begin, _end).first;
2867 template <
typename P>
2870 internal_clear(root());
2872 mutable_root() = EmptyNode();
2873 rightmost_ = EmptyNode();
2877 template <
typename P>
2883 swap(root_, x.
root_);
2891 swap(size_, x.
size_);
2894 template <
typename P>
2896 assert(root() !=
nullptr);
2897 assert(leftmost() !=
nullptr);
2898 assert(rightmost_ !=
nullptr);
2899 assert(empty() || size() == internal_verify(root(),
nullptr,
nullptr));
2901 assert(rightmost_ == (--
const_iterator(root(), root()->count())).node);
2902 assert(leftmost()->leaf());
2903 assert(rightmost_->leaf());
2906 template <
typename P>
2909 int &insert_position = iter->
position;
2911 assert(kNodeValues == node->
max_count());
2915 if (node != root()) {
2919 assert(left->
max_count() == kNodeValues);
2920 if (left->
count() < kNodeValues) {
2924 int to_move = (kNodeValues - left->
count()) /
2925 (1 + (insert_position < kNodeValues));
2926 to_move = (std::max)(1, to_move);
2928 if (((insert_position - to_move) >= 0) ||
2929 ((left->
count() + to_move) < kNodeValues)) {
2933 insert_position = insert_position - to_move;
2934 if (insert_position < 0) {
2935 insert_position = insert_position + left->
count() + 1;
2948 assert(right->
max_count() == kNodeValues);
2949 if (right->
count() < kNodeValues) {
2954 (kNodeValues - right->
count()) / (1 + (insert_position > 0));
2955 to_move = (std::max)(1, to_move);
2957 if ((insert_position <= (node->
count() - to_move)) ||
2958 ((right->
count() + to_move) < kNodeValues)) {
2961 if (insert_position > node->
count()) {
2962 insert_position = insert_position - node->
count() - 1;
2974 assert(parent->
max_count() == kNodeValues);
2975 if (parent->
count() == kNodeValues) {
2977 rebalance_or_split(&parent_iter);
2983 parent = new_internal_node(parent);
2985 mutable_root() = parent;
2987 assert(!parent->
child(0)->
leaf() || parent->
child(0) == rightmost_);
2993 split_node = new_leaf_node(parent);
2994 node->
split(insert_position, split_node, mutable_allocator());
2995 if (rightmost_ == node) rightmost_ = split_node;
2997 split_node = new_internal_node(parent);
2998 node->
split(insert_position, split_node, mutable_allocator());
3001 if (insert_position > node->
count()) {
3002 insert_position = insert_position - node->
count() - 1;
3007 template <
typename P>
3009 left->
merge(right, mutable_allocator());
3010 if (right->
leaf()) {
3011 if (rightmost_ == right) rightmost_ = left;
3012 delete_leaf_node(right);
3014 delete_internal_node(right);
3018 template <
typename P>
3021 if (iter->
node->position() > 0) {
3024 assert(left->
max_count() == kNodeValues);
3025 if ((1 + left->
count() + iter->
node->count()) <= kNodeValues) {
3027 merge_nodes(left, iter->
node);
3032 if (iter->
node->position() < parent->
count()) {
3035 assert(right->
max_count() == kNodeValues);
3036 if ((1 + iter->
node->count() + right->
count()) <= kNodeValues) {
3037 merge_nodes(iter->
node, right);
3044 if ((right->
count() > kMinNodeValues) &&
3045 ((iter->
node->count() == 0) ||
3047 int to_move = (right->
count() - iter->
node->count()) / 2;
3048 to_move = (std::min)(to_move, right->
count() - 1);
3049 iter->
node->rebalance_right_to_left(to_move, right, mutable_allocator());
3053 if (iter->
node->position() > 0) {
3059 if ((left->
count() > kMinNodeValues) &&
3060 ((iter->
node->count() == 0) ||
3062 int to_move = (left->
count() - iter->
node->count()) / 2;
3063 to_move = (std::min)(to_move, left->
count() - 1);
3072 template <
typename P>
3074 if (root()->count() > 0) {
3078 if (root()->leaf()) {
3079 assert(size() == 0);
3080 delete_leaf_node(root());
3081 mutable_root() = EmptyNode();
3082 rightmost_ = EmptyNode();
3086 delete_internal_node(root());
3087 mutable_root() = child;
3091 template <
typename P>
3092 template <
typename IterType>
3094 assert(iter.node !=
nullptr);
3095 while (iter.position == iter.node->count()) {
3096 iter.position = iter.node->position();
3097 iter.node = iter.node->parent();
3098 if (iter.node->leaf()) {
3099 iter.node =
nullptr;
3106 template <
typename P>
3107 template <
typename... Args>
3110 if (!iter.node->leaf()) {
3116 const int max_count = iter.node->max_count();
3117 if (iter.node->count() == max_count) {
3119 if (max_count < kNodeValues) {
3122 assert(iter.node == root());
3124 new_leaf_root_node((std::min<int>)(kNodeValues, 2 * max_count));
3125 iter.node->swap(root(), mutable_allocator());
3126 delete_leaf_node(root());
3127 mutable_root() = iter.node;
3128 rightmost_ = iter.node;
3130 rebalance_or_split(&iter);
3133 iter.node->emplace_value(iter.position, mutable_allocator(),
3134 std::forward<Args>(args)...);
3139 template <
typename P>
3140 template <
typename K>
3146 template <
typename P>
3147 template <
typename K>
3149 const K &key, std::false_type )
const
3153 iter.
position = iter.
node->lower_bound(key, key_comp()).value;
3158 if (iter.
node->leaf()) {
3166 template <
typename P>
3167 template <
typename K>
3169 const K &key, std::true_type )
const
3178 if (iter.
node->leaf()) {
3186 template <
typename P>
3187 template <
typename K>
3191 iter.
position = iter.
node->lower_bound(key, key_comp()).value;
3192 if (iter.
node->leaf()) {
3197 return internal_last(iter);
3200 template <
typename P>
3201 template <
typename K>
3205 iter.
position = iter.
node->upper_bound(key, key_comp());
3206 if (iter.
node->leaf()) {
3211 return internal_last(iter);
3214 template <
typename P>
3215 template <
typename K>
3217 auto res = internal_locate(key);
3218 if (res.HasMatch()) {
3223 const iterator iter = internal_last(res.value);
3224 if (iter.
node !=
nullptr && !compare_keys(key, iter.
key())) {
3228 return {
nullptr, 0};
3231 template <
typename P>
3233 if (!node->
leaf()) {
3234 for (
int i = 0; i <= node->
count(); ++i) {
3235 internal_clear(node->
child(i));
3237 delete_internal_node(node);
3239 delete_leaf_node(node);
3243 template <
typename P>
3246 assert(node->
count() > 0);
3249 assert(!compare_keys(node->
key(0), *lo));
3252 assert(!compare_keys(*hi, node->
key(node->
count() - 1)));
3254 for (
int i = 1; i < node->
count(); ++i) {
3255 assert(!compare_keys(node->
key(i), node->
key(i - 1)));
3258 if (!node->
leaf()) {
3259 for (
int i = 0; i <= node->
count(); ++i) {
3260 assert(node->
child(i) !=
nullptr);
3263 count += internal_verify(
3265 (i == 0) ? lo : &node->
key(i - 1),
3266 (i == node->
count()) ? hi : &node->
key(i));
3274 template <
typename Tree>
3286 template type<K, typename Tree::key_type>;
3310 :
tree_(comp, alloc) {}
3315 std::is_nothrow_move_assignable<Tree>::value) =
default;
3333 template <
typename K = key_type>
3338 template <
typename K = key_type>
3340 return tree_.find(key);
3342 template <
typename K = key_type>
3345 template <
typename K = key_type>
3348 template <
typename K = key_type>
3351 template <
typename K = key_type>
3354 template <
typename K = key_type>
3357 template <
typename K = key_type>
3360 template <
typename K = key_type>
3363 template <
typename K = key_type>
3366 return tree_.equal_range(key);
3374 template <
typename K = key_type>
3382 auto node = CommonAccess::Move<node_type>(
get_allocator(), position.slot());
3401 if (x.
size() != y.
size())
return false;
3408 return std::lexicographical_compare(x.
begin(), x.
end(), y.
begin(), y.
end());
3425 template <
typename State>
3427 for (
const auto &v : b) {
3428 h = State::combine(std::move(h), v);
3430 return State::combine(std::move(h), b.
size());
3439 template <
typename Tree>
3461 using super_type::super_type;
3464 template <
class InputIterator>
3482 template <
typename K = key_type>
3484 return this->
tree_.count_unique(key);
3489 return this->
tree_.insert_unique(params_type::key(x), x);
3492 return this->
tree_.insert_unique(params_type::key(x), std::move(x));
3494 template <
typename... Args>
3495 std::pair<iterator, bool>
emplace(Args &&... args) {
3496 init_type v(std::forward<Args>(args)...);
3497 return this->
tree_.insert_unique(params_type::key(v), std::move(v));
3501 .insert_hint_unique(
iterator(hint), params_type::key(x), x)
3506 .insert_hint_unique(
iterator(hint), params_type::key(x),
3511 template <
typename... Args>
3513 init_type v(std::forward<Args>(args)...);
3515 .insert_hint_unique(
iterator(hint), params_type::key(v),
3520 template <
typename InputIterator>
3521 void insert(InputIterator b, InputIterator e) {
3522 this->
tree_.insert_iterator_unique(b, e);
3525 void insert(std::initializer_list<init_type> init) {
3526 this->
tree_.insert_iterator_unique(init.begin(), init.end());
3531 std::pair<iterator, bool> res =
3538 return {res.first,
false, std::move(node)};
3543 if (!node)
return this->
end();
3544 std::pair<iterator, bool> res = this->
tree_.insert_hint_unique(
3551 template <
typename K = key_type>
3555 template <
typename K = key_type>
3557 auto it = this->
find(key);
3570 std::is_same<value_type, typename T::value_type>,
3571 std::is_same<allocator_type, typename T::allocator_type>,
3572 std::is_same<
typename params_type::is_map_container,
3573 typename T::params_type::is_map_container>>::value,
3576 for (
auto src_it = src.
begin(); src_it != src.
end();) {
3577 if (
insert(std::move(*src_it)).second) {
3578 src_it = src.
erase(src_it);
3589 std::is_same<value_type, typename T::value_type>,
3590 std::is_same<allocator_type, typename T::allocator_type>,
3591 std::is_same<
typename params_type::is_map_container,
3592 typename T::params_type::is_map_container>>::value,
3601 template <
typename Tree>
3624 template <
typename... Args>
3626 return this->
tree_.insert_unique(
3627 k, std::piecewise_construct, std::forward_as_tuple(k),
3628 std::forward_as_tuple(std::forward<Args>(args)...));
3630 template <
typename... Args>
3637 return this->
tree_.insert_unique(
3638 key_ref, std::piecewise_construct, std::forward_as_tuple(std::move(k)),
3639 std::forward_as_tuple(std::forward<Args>(args)...));
3641 template <
typename... Args>
3645 .insert_hint_unique(
iterator(hint), k, std::piecewise_construct,
3646 std::forward_as_tuple(k),
3647 std::forward_as_tuple(std::forward<Args>(args)...))
3650 template <
typename... Args>
3658 .insert_hint_unique(
iterator(hint), key_ref, std::piecewise_construct,
3659 std::forward_as_tuple(std::move(k)),
3660 std::forward_as_tuple(std::forward<Args>(args)...))
3670 template <
typename K = key_type>
3672 auto it = this->
find(key);
3673 if (it == this->
end())
3677 template <
typename K = key_type>
3679 auto it = this->
find(key);
3680 if (it == this->
end())
3687 template <
typename Tree>
3708 using super_type::super_type;
3712 template <
class InputIterator>
3727 template <
typename K = key_type>
3729 return this->
tree_.count_multi(key);
3735 return this->
tree_.insert_multi(std::move(x));
3741 return this->
tree_.insert_hint_multi(
iterator(hint), std::move(x));
3743 template <
typename InputIterator>
3744 void insert(InputIterator b, InputIterator e) {
3745 this->
tree_.insert_iterator_multi(b, e);
3747 void insert(std::initializer_list<init_type> init) {
3748 this->
tree_.insert_iterator_multi(init.begin(), init.end());
3750 template <
typename... Args>
3752 return this->
tree_.insert_multi(
init_type(std::forward<Args>(args)...));
3754 template <
typename... Args>
3756 return this->
tree_.insert_hint_multi(
3760 if (!node)
return this->
end();
3768 if (!node)
return this->
end();
3777 template <
typename K = key_type>
3779 return this->
tree_.erase_multi(key);
3784 template <
typename K = key_type>
3786 auto it = this->
find(key);
3797 std::is_same<value_type, typename T::value_type>,
3798 std::is_same<allocator_type, typename T::allocator_type>,
3799 std::is_same<
typename params_type::is_map_container,
3800 typename T::params_type::is_map_container>>::value,
3804 std::make_move_iterator(src.
end()));
3812 std::is_same<value_type, typename T::value_type>,
3813 std::is_same<allocator_type, typename T::allocator_type>,
3814 std::is_same<
typename params_type::is_map_container,
3815 typename T::params_type::is_map_container>>::value,
3823 template <
typename Tree>
3843 template <
typename Key,
typename Compare,
typename Alloc>
3845 priv::btree<priv::set_params<
3846 Key, Compare, Alloc, 256, false>>>
3858 using Base::max_size;
3863 using Base::emplace;
3864 using Base::emplace_hint;
3865 using Base::extract;
3868 using Base::contains;
3870 using Base::equal_range;
3871 using Base::lower_bound;
3872 using Base::upper_bound;
3874 using Base::get_allocator;
3875 using Base::key_comp;
3876 using Base::value_comp;
3881 template <
typename K,
typename C,
typename A>
3888 template <
typename K,
typename C,
typename A,
typename Pred>
3890 for (
auto it = set.
begin(); it != set.
end();) {
3902 template <
typename Key,
typename Compare,
typename Alloc>
3904 priv::btree<priv::set_params<
3905 Key, Compare, Alloc, 256, true>>>
3917 using Base::max_size;
3922 using Base::emplace;
3923 using Base::emplace_hint;
3924 using Base::extract;
3927 using Base::contains;
3929 using Base::equal_range;
3930 using Base::lower_bound;
3931 using Base::upper_bound;
3933 using Base::get_allocator;
3934 using Base::key_comp;
3935 using Base::value_comp;
3940 template <
typename K,
typename C,
typename A>
3947 template <
typename K,
typename C,
typename A,
typename Pred>
3949 for (
auto it = set.
begin(); it != set.
end();) {
3962 template <
typename Key,
typename Value,
typename Compare,
typename Alloc>
3964 priv::btree<priv::map_params<
3965 Key, Value, Compare, Alloc, 256, false>>>
3977 using Base::max_size;
3982 using Base::emplace;
3983 using Base::emplace_hint;
3984 using Base::try_emplace;
3985 using Base::extract;
3989 using Base::contains;
3991 using Base::equal_range;
3992 using Base::lower_bound;
3993 using Base::upper_bound;
3995 using Base::operator[];
3996 using Base::get_allocator;
3997 using Base::key_comp;
3998 using Base::value_comp;
4003 template <
typename K,
typename V,
typename C,
typename A>
4009 template <
typename K,
typename V,
typename C,
typename A,
typename Pred>
4011 for (
auto it = map.
begin(); it != map.
end();) {
4023 template <
typename Key,
typename Value,
typename Compare,
typename Alloc>
4025 priv::btree<priv::map_params<
4026 Key, Value, Compare, Alloc, 256, true>>>
4038 using Base::max_size;
4043 using Base::emplace;
4044 using Base::emplace_hint;
4045 using Base::extract;
4048 using Base::contains;
4050 using Base::equal_range;
4051 using Base::lower_bound;
4052 using Base::upper_bound;
4054 using Base::get_allocator;
4055 using Base::key_comp;
4056 using Base::value_comp;
4061 template <
typename K,
typename V,
typename C,
typename A>
4068 template <
typename K,
typename V,
typename C,
typename A,
typename Pred>
4070 for (
auto it = map.
begin(); it != map.
end();) {
4083 #pragma warning(pop)
#define PHMAP_COMPARE_INLINE_SUBCLASS_DECL(type, name)
Definition: btree.h:266
#define PHMAP_COMPARE_INLINE_INIT(type, name, init)
Definition: btree.h:268
#define PHMAP_COMPARE_INLINE_BASECLASS_DECL(name)
Definition: btree.h:263
typename btree_map::btree_map_container Base
Definition: btree.h:3967
btree_map()
Definition: btree.h:3970
typename btree_multimap::btree_multimap_container Base
Definition: btree.h:4028
btree_multimap()
Definition: btree.h:4031
btree_multiset()
Definition: btree.h:3910
typename btree_multiset::btree_multiset_container Base
Definition: btree.h:3907
btree_set()
Definition: btree.h:3851
typename btree_set::btree_set_container Base
Definition: btree.h:3848
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
Definition: btree.h:450
constexpr partial_ordering(compare_internal::eq v) noexcept
Definition: btree.h:401
friend constexpr bool operator>=(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
Definition: btree.h:470
friend constexpr bool operator==(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:426
friend constexpr bool operator>(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
Definition: btree.h:466
compare_internal::value_type value_
Definition: btree.h:476
constexpr partial_ordering(compare_internal::ord v) noexcept
Definition: btree.h:403
friend constexpr bool operator<=(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
Definition: btree.h:462
friend constexpr bool operator!=(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:430
friend constexpr bool operator<(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:434
friend constexpr bool operator>=(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:446
friend constexpr bool operator>(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:442
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
Definition: btree.h:454
constexpr bool is_ordered() const noexcept
Definition: btree.h:409
friend constexpr bool operator<(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
Definition: btree.h:458
friend constexpr bool operator<=(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:438
Definition: phmap_base.h:4286
Definition: phmap_base.h:4129
typename Tree::value_type value_type
Definition: btree.h:3290
typename Tree::allocator_type allocator_type
Definition: btree.h:3295
void swap(btree_container &x)
Definition: btree.h:3393
typename KeyArg< IsTransparent< typename Tree::key_compare >::value >::template type< K, typename Tree::key_type > key_arg
Definition: btree.h:3286
const_iterator cend() const
Definition: btree.h:3323
const_iterator end() const
Definition: btree.h:3322
const_reverse_iterator crbegin() const
Definition: btree.h:3326
size_type size() const
Definition: btree.h:3396
node_type extract(iterator position)
Definition: btree.h:3379
reverse_iterator rend()
Definition: btree.h:3327
value_compare value_comp() const
Definition: btree.h:3422
const_reverse_iterator rbegin() const
Definition: btree.h:3325
typename Tree::value_compare value_compare
Definition: btree.h:3294
iterator erase(const_iterator first, const_iterator last)
Definition: btree.h:3371
const_iterator find(const key_arg< K > &key) const
Definition: btree.h:3343
iterator erase(const_iterator iter)
Definition: btree.h:3369
typename Tree::key_compare key_compare
Definition: btree.h:3293
const_iterator cbegin() const
Definition: btree.h:3320
iterator find(const key_arg< K > &key)
Definition: btree.h:3339
friend bool operator>=(const btree_container &x, const btree_container &y)
Definition: btree.h:3415
friend bool operator<(const btree_container &x, const btree_container &y)
Definition: btree.h:3407
const_iterator upper_bound(const key_arg< K > &key) const
Definition: btree.h:3358
const_iterator begin() const
Definition: btree.h:3319
btree_container(const btree_container &x)=default
friend State AbslHashValue(State h, const btree_container &b)
Definition: btree.h:3426
const_reverse_iterator rend() const
Definition: btree.h:3328
std::pair< const_iterator, const_iterator > equal_range(const key_arg< K > &key) const
Definition: btree.h:3364
iterator begin()
Definition: btree.h:3318
void verify() const
Definition: btree.h:3394
iterator upper_bound(const key_arg< K > &key)
Definition: btree.h:3355
btree_container()
Definition: btree.h:3307
typename Tree::reference reference
Definition: btree.h:3296
btree_container & operator=(btree_container &&x) noexcept(std::is_nothrow_move_assignable< Tree >::value)=default
const_reverse_iterator crend() const
Definition: btree.h:3329
friend bool operator<=(const btree_container &x, const btree_container &y)
Definition: btree.h:3413
typename Tree::node_handle_type node_type
Definition: btree.h:3304
typename Tree::reverse_iterator reverse_iterator
Definition: btree.h:3302
iterator end()
Definition: btree.h:3321
void clear()
Definition: btree.h:3392
key_compare key_comp() const
Definition: btree.h:3421
typename Tree::iterator iterator
Definition: btree.h:3300
typename Tree::const_reference const_reference
Definition: btree.h:3297
btree_container(btree_container &&x) noexcept=default
size_type max_size() const
Definition: btree.h:3397
typename Tree::difference_type difference_type
Definition: btree.h:3292
Tree tree_
Definition: btree.h:3434
typename Tree::pointer pointer
Definition: btree.h:3298
iterator erase(iterator iter)
Definition: btree.h:3370
typename Tree::const_iterator const_iterator
Definition: btree.h:3301
btree_container(const key_compare &comp, const allocator_type &alloc=allocator_type())
Definition: btree.h:3308
friend bool operator==(const btree_container &x, const btree_container &y)
Definition: btree.h:3400
typename Tree::size_type size_type
Definition: btree.h:3291
size_type count(const key_arg< K > &key) const
Definition: btree.h:3334
bool empty() const
Definition: btree.h:3398
btree_container & operator=(const btree_container &x)=default
typename Tree::key_type key_type
Definition: btree.h:3289
friend bool operator>(const btree_container &x, const btree_container &y)
Definition: btree.h:3411
allocator_type get_allocator() const
Definition: btree.h:3418
node_type extract(const_iterator position)
Definition: btree.h:3387
bool contains(const key_arg< K > &key) const
Definition: btree.h:3346
friend bool operator!=(const btree_container &x, const btree_container &y)
Definition: btree.h:3405
typename Tree::const_reverse_iterator const_reverse_iterator
Definition: btree.h:3303
const_iterator lower_bound(const key_arg< K > &key) const
Definition: btree.h:3352
reverse_iterator rbegin()
Definition: btree.h:3324
typename Tree::const_pointer const_pointer
Definition: btree.h:3299
typename Tree::params_type params_type
Definition: btree.h:3276
iterator lower_bound(const key_arg< K > &key)
Definition: btree.h:3349
std::pair< iterator, iterator > equal_range(const key_arg< K > &key)
Definition: btree.h:3361
size_type erase(const key_arg< K > &key)
Definition: btree.h:3375
typename Tree::iterator iterator
Definition: btree.h:3616
typename Tree::const_iterator const_iterator
Definition: btree.h:3617
iterator try_emplace(const_iterator hint, key_type &&k, Args &&... args)
Definition: btree.h:3651
std::pair< iterator, bool > try_emplace(key_type &&k, Args &&... args)
Definition: btree.h:3631
typename Tree::value_type value_type
Definition: btree.h:3613
btree_map_container()
Definition: btree.h:3621
mapped_type & operator[](const key_type &k)
Definition: btree.h:3663
mapped_type & at(const key_arg< K > &key)
Definition: btree.h:3671
const mapped_type & at(const key_arg< K > &key) const
Definition: btree.h:3678
iterator try_emplace(const_iterator hint, const key_type &k, Args &&... args)
Definition: btree.h:3642
std::pair< iterator, bool > try_emplace(const key_type &k, Args &&... args)
Definition: btree.h:3625
typename Tree::params_type params_type
Definition: btree.h:3604
typename Tree::key_type key_type
Definition: btree.h:3611
typename super_type::template key_arg< K > key_arg
Definition: btree.h:3608
mapped_type & operator[](key_type &&k)
Definition: btree.h:3666
typename params_type::mapped_type mapped_type
Definition: btree.h:3612
typename Tree::key_compare key_compare
Definition: btree.h:3614
typename Tree::allocator_type allocator_type
Definition: btree.h:3615
typename Tree::params_type params_type
Definition: btree.h:3826
typename params_type::mapped_type mapped_type
Definition: btree.h:3829
btree_multimap_container()
Definition: btree.h:3833
btree_multiset_container(std::initializer_list< init_type > init, const key_compare &comp=key_compare(), const allocator_type &alloc=allocator_type())
Definition: btree.h:3721
void insert(InputIterator b, InputIterator e)
Definition: btree.h:3744
typename Tree::value_type value_type
Definition: btree.h:3699
size_type count(const key_arg< K > &key) const
Definition: btree.h:3728
iterator insert(const_iterator hint, value_type &&x)
Definition: btree.h:3740
typename params_type::init_type init_type
Definition: btree.h:3691
iterator insert(const value_type &x)
Definition: btree.h:3733
iterator insert(value_type &&x)
Definition: btree.h:3734
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: btree.h:3755
iterator insert(const_iterator hint, node_type &&node)
Definition: btree.h:3767
iterator insert(node_type &&node)
Definition: btree.h:3759
typename Tree::allocator_type allocator_type
Definition: btree.h:3702
iterator emplace(Args &&... args)
Definition: btree.h:3751
iterator insert(const_iterator hint, const value_type &x)
Definition: btree.h:3737
node_type extract(const key_arg< K > &key)
Definition: btree.h:3785
btree_multiset_container(InputIterator b, InputIterator e, const key_compare &comp=key_compare(), const allocator_type &alloc=allocator_type())
Definition: btree.h:3713
void merge(btree_container< T > &&src)
Definition: btree.h:3817
typename Tree::key_type key_type
Definition: btree.h:3698
typename Tree::params_type params_type
Definition: btree.h:3690
typename Tree::const_iterator const_iterator
Definition: btree.h:3704
void merge(btree_container< T > &src)
Definition: btree.h:3802
size_type erase(const key_arg< K > &key)
Definition: btree.h:3778
typename Tree::size_type size_type
Definition: btree.h:3700
typename Tree::iterator iterator
Definition: btree.h:3703
btree_multiset_container()
Definition: btree.h:3709
void insert(std::initializer_list< init_type > init)
Definition: btree.h:3747
typename params_type::is_key_compare_to is_key_compare_to
Definition: btree.h:3692
typename Tree::key_compare key_compare
Definition: btree.h:3701
typename super_type::template key_arg< K > key_arg
Definition: btree.h:3695
typename super_type::node_type node_type
Definition: btree.h:3705
SearchResult< int, true > linear_search_impl(const K &k, int s, const int e, const Compare &comp, std::true_type) const
Definition: btree.h:1283
SearchResult< int, is_key_compare_to::value > lower_bound(const K &k, const key_compare &comp) const
Definition: btree.h:1238
static btree_node * init_leaf(btree_node *n, btree_node *parent, int max_cnt)
Definition: btree.h:1386
field_type max_count() const
Definition: btree.h:1188
phmap::priv::Layout< btree_node *, field_type, slot_type, btree_node * > layout_type
Definition: btree.h:1093
static constexpr size_type Alignment()
Definition: btree.h:1082
typename Params::reference reference
Definition: btree.h:1058
const_reference value(size_type i) const
Definition: btree.h:1211
const slot_type * slot(size_type i) const
Definition: btree.h:1169
field_type start() const
Definition: btree.h:1184
const layout_type::template ElementType< N > * GetField() const
Definition: btree.h:1160
void value_init(const size_type i, allocator_type *alloc, Args &&... args)
Definition: btree.h:1420
typename Params::const_pointer const_pointer
Definition: btree.h:1057
typename Params::difference_type difference_type
Definition: btree.h:1062
layout_type::template ElementType< N > * GetField()
Definition: btree.h:1153
typename Params::pointer pointer
Definition: btree.h:1056
static bool testonly_uses_linear_node_search()
Definition: btree.h:1414
field_type & mutable_count()
Definition: btree.h:1167
reference value(size_type i)
Definition: btree.h:1210
void value_destroy(const size_type i, allocator_type *alloc)
Definition: btree.h:1424
SearchResult< int, btree_is_key_compare_to< Compare, key_type >::value > linear_search(const K &k, const Compare &comp) const
Definition: btree.h:1253
static constexpr size_type SizeWithNValues(size_type n)
Definition: btree.h:1094
static constexpr size_type InternalSize()
Definition: btree.h:1146
typename Params::node_count_type field_type
Definition: btree.h:1048
void init_child(int i, btree_node *c)
Definition: btree.h:1231
void set_start(field_type v)
Definition: btree.h:1171
SearchResult< int, btree_is_key_compare_to< Compare, key_type >::value > binary_search(const K &k, const Compare &comp) const
Definition: btree.h:1260
void destroy(allocator_type *alloc)
Definition: btree.h:1406
btree_node * child(size_type i) const
Definition: btree.h:1218
void clear_child(size_type i)
Definition: btree.h:1220
void value_destroy_n(const size_type i, const size_type n, allocator_type *alloc)
Definition: btree.h:1443
typename Params::key_type key_type
Definition: btree.h:1054
void emplace_value(size_type i, allocator_type *alloc, Args &&... args)
Definition: btree.h:2138
const key_type & key(size_type i) const
Definition: btree.h:1209
void swap(btree_node *src, allocator_type *alloc)
Definition: btree.h:2379
friend class BtreeNodePeer
Definition: btree.h:1454
void split(int insert_position, btree_node *dest, allocator_type *alloc)
Definition: btree.h:2308
void remove_value(int i, allocator_type *alloc)
Definition: btree.h:2162
static constexpr size_type LeafSize(const int max_values=kNodeValues)
Definition: btree.h:1143
field_type position() const
Definition: btree.h:1181
bool leaf() const
Definition: btree.h:1178
void merge(btree_node *sibling, allocator_type *alloc)
Definition: btree.h:2349
btree_node * parent() const
Definition: btree.h:1198
slot_type * slot(size_type i)
Definition: btree.h:1168
void uninitialized_move_n(const size_type n, const size_type i, const size_type j, btree_node *x, allocator_type *alloc)
Definition: btree.h:1431
bool is_root() const
Definition: btree.h:1202
void remove_values_ignore_children(int i, size_type to_erase, allocator_type *alloc)
Definition: btree.h:2175
typename Params::key_compare key_compare
Definition: btree.h:1060
static constexpr size_type MinimumOverhead()
Definition: btree.h:1102
@ kNodeTargetValues
Definition: btree.h:1118
@ kTargetNodeSize
Definition: btree.h:1117
field_type count() const
Definition: btree.h:1187
btree_node *& mutable_child(size_type i)
Definition: btree.h:1219
void set_max_count(field_type v)
Definition: btree.h:1173
void set_child(size_type i, btree_node *c)
Definition: btree.h:1223
btree_node & operator=(btree_node const &)=delete
static constexpr layout_type InternalLayout()
Definition: btree.h:1137
static constexpr size_type NodeTargetValues(const int begin, const int end)
Definition: btree.h:1108
typename Params::value_type value_type
Definition: btree.h:1055
int upper_bound(const K &k, const key_compare &comp) const
Definition: btree.h:1245
void rebalance_left_to_right(int to_move, btree_node *right, allocator_type *alloc)
Definition: btree.h:2227
typename Params::is_multi_container is_multi_container
Definition: btree.h:1047
SearchResult< int, true > binary_search_impl(const K &k, int s, int e, const CompareTo &comp, std::true_type) const
Definition: btree.h:1318
SearchResult< int, false > binary_search_impl(const K &k, int s, int e, const Compare &comp, std::false_type) const
Definition: btree.h:1301
typename Params::is_key_compare_to is_key_compare_to
Definition: btree.h:1046
static btree_node * init_internal(btree_node *n, btree_node *parent)
Definition: btree.h:1397
void set_parent(btree_node *p)
Definition: btree.h:1166
std::integral_constant< bool, std::is_arithmetic< key_type >::value &&(std::is_same< phmap::Less< key_type >, key_compare >::value||std::is_same< std::less< key_type >, key_compare >::value||std::is_same< std::greater< key_type >, key_compare >::value)> use_linear_search
Definition: btree.h:1074
typename Params::allocator_type allocator_type
Definition: btree.h:1049
typename Params::const_reference const_reference
Definition: btree.h:1059
Params params_type
Definition: btree.h:1053
void make_root()
Definition: btree.h:1203
static constexpr layout_type LeafLayout(const int max_values=kNodeValues)
Definition: btree.h:1131
void set_position(field_type v)
Definition: btree.h:1170
btree_node(btree_node const &)=delete
void rebalance_right_to_left(int to_move, btree_node *right, allocator_type *alloc)
Definition: btree.h:2183
typename Params::size_type size_type
Definition: btree.h:1061
typename Params::slot_type slot_type
Definition: btree.h:1050
SearchResult< int, false > linear_search_impl(const K &k, int s, const int e, const Compare &comp, std::false_type) const
Definition: btree.h:1268
void set_count(field_type v)
Definition: btree.h:1172
void insert(std::initializer_list< init_type > init)
Definition: btree.h:3525
size_type erase(const key_arg< K > &key)
Definition: btree.h:3552
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: btree.h:3512
std::pair< iterator, bool > insert(const value_type &x)
Definition: btree.h:3488
iterator insert(const_iterator hint, value_type &&x)
Definition: btree.h:3504
typename Tree::params_type params_type
Definition: btree.h:3442
typename Tree::size_type size_type
Definition: btree.h:3454
typename Tree::key_type key_type
Definition: btree.h:3452
void insert(InputIterator b, InputIterator e)
Definition: btree.h:3521
node_type extract(const key_arg< K > &key)
Definition: btree.h:3556
friend class BtreeNodePeer
Definition: btree.h:3445
std::pair< iterator, bool > emplace(Args &&... args)
Definition: btree.h:3495
insert_return_type insert(node_type &&node)
Definition: btree.h:3529
typename Tree::key_compare key_compare
Definition: btree.h:3455
typename Tree::iterator iterator
Definition: btree.h:3457
typename Tree::const_iterator const_iterator
Definition: btree.h:3458
btree_set_container()
Definition: btree.h:3462
typename params_type::is_key_compare_to is_key_compare_to
Definition: btree.h:3444
btree_set_container(InputIterator b, InputIterator e, const key_compare &comp=key_compare(), const allocator_type &alloc=allocator_type())
Definition: btree.h:3465
size_type count(const key_arg< K > &key) const
Definition: btree.h:3483
typename Tree::value_type value_type
Definition: btree.h:3453
typename params_type::init_type init_type
Definition: btree.h:3443
std::pair< iterator, bool > insert(value_type &&x)
Definition: btree.h:3491
void merge(btree_container< T > &src)
Definition: btree.h:3575
iterator insert(const_iterator hint, node_type &&node)
Definition: btree.h:3542
typename super_type::template key_arg< K > key_arg
Definition: btree.h:3449
typename super_type::node_type node_type
Definition: btree.h:3459
btree_set_container(std::initializer_list< init_type > init, const allocator_type &alloc)
Definition: btree.h:3477
typename Tree::allocator_type allocator_type
Definition: btree.h:3456
iterator insert(const_iterator hint, const value_type &x)
Definition: btree.h:3499
btree_set_container(std::initializer_list< init_type > init, const key_compare &comp=key_compare(), const allocator_type &alloc=allocator_type())
Definition: btree.h:3472
void merge(btree_container< T > &&src)
Definition: btree.h:3594
void merge_nodes(node_type *left, node_type *right)
Definition: btree.h:3008
size_type bytes_used() const
Definition: btree.h:1918
size_type internal_verify(const node_type *node, const key_type *lo, const key_type *hi) const
Definition: btree.h:3244
size_type erase_multi(const K &key)
btree_iterator< node_type, reference, pointer > iterator
Definition: btree.h:1671
static node_type * EmptyNode()
Definition: btree.h:1623
size_type count_unique(const K &key) const
Definition: btree.h:1849
std::pair< iterator, bool > insert_unique(const key_type &key, Args &&... args)
static constexpr bool static_assert_validation()
Definition: btree.h:2496
static bool testonly_uses_linear_node_search()
Definition: btree.h:2115
std::pair< iterator, iterator > equal_range(const K &key)
Definition: btree.h:1765
node_type * leftmost()
Definition: btree.h:1970
void delete_internal_node(node_type *node)
Definition: btree.h:2014
bool try_merge_or_rebalance(iterator *iter)
Definition: btree.h:3019
reverse_iterator rbegin()
Definition: btree.h:1728
static IterType internal_last(IterType iter)
Definition: btree.h:3093
bool compare_keys(const K &x, const LK &y) const
Definition: btree.h:1874
iterator internal_emplace(iterator iter, Args &&... args)
void try_shrink()
Definition: btree.h:3073
std::pair< iterator, bool > insert_hint_unique(iterator position, const key_type &key, Args &&... args)
allocator_type get_allocator() const
Definition: btree.h:1958
btree_node< Params > node_type
Definition: btree.h:1600
node_type *& mutable_root() noexcept
Definition: btree.h:1966
void swap(btree &x)
Definition: btree.h:2878
const key_compare & key_comp() const noexcept
Definition: btree.h:1870
const_iterator upper_bound(const K &key) const
Definition: btree.h:1757
const_reverse_iterator rend() const
Definition: btree.h:1737
double fullness() const
Definition: btree.h:1943
size_type size_
Definition: btree.h:2131
void clear()
Definition: btree.h:2868
const_reverse_iterator rbegin() const
Definition: btree.h:1731
bool empty() const
Definition: btree.h:1886
iterator erase_from_leaf_node(iterator begin, size_type to_erase)
Definition: btree.h:2827
iterator internal_end(iterator iter)
Definition: btree.h:2039
btree(btree &&x) noexcept
Definition: btree.h:1700
const allocator_type & allocator() const noexcept
Definition: btree.h:1977
typename Params::const_reference const_reference
Definition: btree.h:1668
SearchResult< iterator, true > internal_locate_impl(const K &key, std::true_type) const
const_iterator find(const K &key) const
Definition: btree.h:1843
iterator end()
Definition: btree.h:1724
typename Params::slot_type slot_type
Definition: btree.h:1679
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition: btree.h:1769
typename Params::reference reference
Definition: btree.h:1667
std::pair< size_type, iterator > erase(iterator begin, iterator end)
Definition: btree.h:2764
void insert_iterator_unique(InputIterator b, InputIterator e)
Definition: btree.h:2589
iterator internal_upper_bound(const K &key) const
iterator insert_multi(ValueType &&v)
Definition: btree.h:1801
iterator internal_lower_bound(const K &key) const
btree & operator=(btree &&x) noexcept
Definition: btree.h:2657
typename Params::is_key_compare_to is_key_compare_to
Definition: btree.h:1601
iterator insert_multi(const key_type &key, ValueType &&v)
iterator rebalance_after_delete(iterator iter)
Definition: btree.h:2724
node_type * new_leaf_root_node(const int max_count)
Definition: btree.h:1998
SearchResult< iterator, is_key_compare_to::value > internal_locate(const K &key) const
node_stats internal_stats(const node_type *node) const
Definition: btree.h:2098
typename iterator::const_iterator const_iterator
Definition: btree.h:1672
static double average_bytes_per_value()
Definition: btree.h:1931
value_compare value_comp() const
Definition: btree.h:1878
reverse_iterator rend()
Definition: btree.h:1734
const_iterator internal_end(const_iterator iter) const
Definition: btree.h:2042
Params params_type
Definition: btree.h:1678
node_type * new_leaf_node(node_type *parent)
Definition: btree.h:1994
double overhead() const
Definition: btree.h:1951
size_type size() const
Definition: btree.h:1884
iterator insert_hint_multi(iterator position, ValueType &&v)
typename Params::key_type key_type
Definition: btree.h:1660
size_type max_size() const
Definition: btree.h:1885
size_type height() const
Definition: btree.h:1889
void verify() const
Definition: btree.h:2895
node_type * allocate(const size_type sz)
Definition: btree.h:1983
node_type * root()
Definition: btree.h:1964
size_type count_multi(const K &key) const
Definition: btree.h:1859
void insert_iterator_multi(InputIterator b, InputIterator e)
Definition: btree.h:2634
node_type * rightmost_
Definition: btree.h:2128
typename Params::value_compare value_compare
Definition: btree.h:1665
@ kMinNodeValues
Definition: btree.h:1638
@ kNodeValues
Definition: btree.h:1637
std::reverse_iterator< iterator > reverse_iterator
Definition: btree.h:1673
iterator begin()
Definition: btree.h:1718
size_type nodes() const
Definition: btree.h:1912
typename Params::const_pointer const_pointer
Definition: btree.h:1670
~btree()
Definition: btree.h:1707
iterator erase(iterator iter)
Definition: btree.h:2688
iterator upper_bound(const K &key)
Definition: btree.h:1753
const node_type * root() const
Definition: btree.h:1965
const_iterator begin() const
Definition: btree.h:1721
key_compare * mutable_key_comp() noexcept
Definition: btree.h:1967
void rebalance_or_split(iterator *iter)
Definition: btree.h:2907
value_type && maybe_move_from_iterator(iterator x)
Definition: btree.h:1684
SearchResult< iterator, false > internal_locate_impl(const K &key, std::false_type) const
void internal_clear(node_type *node)
Definition: btree.h:3232
typename Params::pointer pointer
Definition: btree.h:1669
typename Params::allocator_type allocator_type
Definition: btree.h:1666
const node_type * leftmost() const
Definition: btree.h:1971
btree & operator=(const btree &x)
Definition: btree.h:2641
void delete_leaf_node(node_type *node)
Definition: btree.h:2018
typename Params::difference_type difference_type
Definition: btree.h:1663
allocator_type * mutable_allocator() noexcept
Definition: btree.h:1974
const_iterator end() const
Definition: btree.h:1725
typename Params::size_type size_type
Definition: btree.h:1662
iterator internal_find(const K &key) const
iterator find(const K &key)
Definition: btree.h:1839
iterator lower_bound(const K &key)
Definition: btree.h:1743
const_iterator lower_bound(const K &key) const
Definition: btree.h:1747
phmap::priv::CompressedTuple< key_compare, allocator_type, node_type * > root_
Definition: btree.h:2124
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: btree.h:1674
size_type internal_nodes() const
Definition: btree.h:1909
void deallocate(const size_type sz, node_type *node)
Definition: btree.h:2009
const value_type & maybe_move_from_iterator(const_iterator x)
Definition: btree.h:1683
btree(const btree &x)
Definition: btree.h:2531
btree(const key_compare &comp, const allocator_type &alloc)
Definition: btree.h:2527
typename Params::value_type value_type
Definition: btree.h:1661
typename Params::key_compare key_compare
Definition: btree.h:1664
void copy_or_move_values_in_order(Btree *x)
Definition: btree.h:2476
node_type * new_internal_node(node_type *parent)
Definition: btree.h:1990
size_type leaf_nodes() const
Definition: btree.h:1906
size_type erase_unique(const K &key)
void erase_same_node(iterator begin, iterator end)
Definition: btree.h:2799
Definition: phmap_base.h:2833
friend constexpr bool operator!=(strong_equality v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:374
compare_internal::value_type value_
Definition: btree.h:388
friend constexpr bool operator==(strong_equality v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:370
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, strong_equality v) noexcept
Definition: btree.h:378
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, strong_equality v) noexcept
Definition: btree.h:382
friend constexpr bool operator<(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
Definition: btree.h:635
friend constexpr bool operator<(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:611
friend constexpr bool operator==(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:603
friend constexpr bool operator<=(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
Definition: btree.h:639
friend constexpr bool operator>(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:619
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
Definition: btree.h:627
constexpr strong_ordering(compare_internal::eq v) noexcept
Definition: btree.h:572
friend constexpr bool operator>(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
Definition: btree.h:643
friend constexpr bool operator>=(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:623
friend constexpr bool operator<=(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:615
friend constexpr bool operator>=(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
Definition: btree.h:647
compare_internal::value_type value_
Definition: btree.h:653
friend constexpr bool operator!=(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:607
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
Definition: btree.h:631
typename std::remove_all_extents< T >::type ExtentsRemoved
Definition: btree.h:148
static constexpr bool kIsCopyOrMoveAssignable
Definition: btree.h:152
static constexpr bool kIsCopyOrMoveConstructible
Definition: btree.h:149
static constexpr bool kValue
Definition: btree.h:157
friend constexpr bool operator!=(weak_equality v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:331
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, weak_equality v) noexcept
Definition: btree.h:335
compare_internal::value_type value_
Definition: btree.h:345
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, weak_equality v) noexcept
Definition: btree.h:339
friend constexpr bool operator<(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
Definition: btree.h:543
compare_internal::value_type value_
Definition: btree.h:561
friend constexpr bool operator>=(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
Definition: btree.h:555
constexpr weak_ordering(compare_internal::eq v) noexcept
Definition: btree.h:489
friend constexpr bool operator>(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:527
friend constexpr bool operator!=(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:515
friend constexpr bool operator<(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:519
friend constexpr bool operator==(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:511
friend constexpr bool operator<=(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:523
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
Definition: btree.h:535
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
Definition: btree.h:539
friend constexpr bool operator>=(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
Definition: btree.h:531
friend constexpr bool operator<=(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
Definition: btree.h:547
friend constexpr bool operator>(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
Definition: btree.h:551
static void ThrowStdOutOfRange(const std::string &what_arg)
Definition: phmap_base.h:694
constexpr phmap::weak_ordering compare_result_as_ordering(const Int c)
Definition: btree.h:690
constexpr bool do_less_than_comparison(const Compare &compare, const K &x, const LK &y)
Definition: btree.h:680
constexpr bool compare_result_as_less_than(const BoolType r)
Definition: btree.h:674
int8_t value_type
Definition: btree.h:220
constexpr phmap::weak_ordering do_three_way_comparison(const Compare &compare, const K &x, const LK &y)
Definition: btree.h:705
eq
Definition: btree.h:240
ord
Definition: btree.h:247
ncmp
Definition: btree.h:249
std::is_convertible< phmap::invoke_result_t< Compare, const T &, const T & >, phmap::weak_ordering > btree_is_key_compare_to
Definition: btree.h:734
MatchKind
Definition: btree.h:1019
void SanitizerPoisonObject(const T *object)
Definition: phmap_base.h:4407
void SanitizerUnpoisonObject(const T *object)
Definition: phmap_base.h:4412
void SanitizerPoisonMemoryRegion(const void *m, size_t s)
Definition: phmap_base.h:4384
void SanitizerUnpoisonMemoryRegion(const void *m, size_t s)
Definition: phmap_base.h:4395
void Swap(T &lhs, T &rhs) noexcept(IsNothrowSwappable< T >::value)
Definition: btree.h:200
typename std::enable_if< IsNoexcept::value >::type IsNothrowSwappableImpl
Definition: btree.h:189
decltype(swap(std::declval< T & >(), std::declval< T & >())) IsSwappableImpl
Definition: btree.h:183
typename std::conditional< B, T, F >::type conditional_t
Definition: phmap_base.h:322
T exchange(T &obj, U &&new_value)
Definition: phmap_base.h:1127
void erase_if(btree_set< K, C, A > &set, Pred pred)
Definition: btree.h:3889
typename std::result_of< F(ArgTypes...)>::type invoke_result_t
Definition: phmap_base.h:335
typename std::enable_if< B, T >::type enable_if_t
Definition: phmap_base.h:319
typename type_traits_internal::VoidTImpl< Ts... >::type void_t
Definition: btree.h:134
#define false
Definition: stdbool.h:33
unsigned char bool
Definition: stdbool.h:25
Definition: phmap_base.h:85
Definition: phmap_base.h:1379
static void construct(Alloc &a, T *p, Args &&... args)
Definition: phmap_base.h:1491
static void destroy(Alloc &a, T *p)
Definition: phmap_base.h:1499
constexpr OnlyLiteralZero(NullPtrT) noexcept
Definition: btree.h:229
Definition: phmap_base.h:200
Definition: phmap_base.h:163
Definition: phmap_base.h:168
Definition: phmap_base.h:242
static auto GetSlot(const Node &node) -> decltype(node.slot())
Definition: phmap_base.h:2885
static void Destroy(Node *node)
Definition: phmap_base.h:2890
Definition: phmap_base.h:2918
Definition: phmap_base.h:2723
static constexpr bool HasMatch()
Definition: btree.h:1037
V value
Definition: btree.h:1035
static constexpr bool IsEq()
Definition: btree.h:1038
V value
Definition: btree.h:1023
bool IsEq() const
Definition: btree.h:1027
MatchKind match
Definition: btree.h:1024
static constexpr bool HasMatch()
Definition: btree.h:1026
phmap::weak_ordering operator()(std::string lhs, std::string rhs) const
Definition: btree.h:773
StringBtreeDefaultGreater(std::greater< std::string >)
Definition: btree.h:764
void is_transparent
Definition: btree.h:760
StringBtreeDefaultGreater()=default
StringBtreeDefaultLess(std::less< std::string >)
Definition: btree.h:742
phmap::weak_ordering operator()(std::string lhs, std::string rhs) const
Definition: btree.h:752
StringBtreeDefaultLess()=default
void is_transparent
Definition: btree.h:737
node_type * parent
Definition: btree.h:1607
field_type position
Definition: btree.h:1608
constexpr EmptyNodeType(node_type *p)
Definition: btree.h:1619
field_type count
Definition: btree.h:1610
field_type start
Definition: btree.h:1609
field_type max_count
Definition: btree.h:1613
typename node_type::field_type field_type
Definition: btree.h:1606
size_type leaf_nodes
Definition: btree.h:1655
typename Params::size_type size_type
Definition: btree.h:1642
size_type internal_nodes
Definition: btree.h:1656
node_stats(size_type l, size_type i)
Definition: btree.h:1644
node_stats & operator+=(const node_stats &x)
Definition: btree.h:1649
Node * node
Definition: btree.h:1592
const key_type & key() const
Definition: btree.h:1588
btree_iterator & operator--()
Definition: btree.h:1557
btree_iterator(const btree_iterator< N, R, P > &x)
Definition: btree.h:1498
Node node_type
Definition: btree.h:1464
Reference reference
Definition: btree.h:1483
typename std::remove_const< Node >::type normal_node
Definition: btree.h:1465
bool operator!=(const iterator &x) const
Definition: btree.h:1541
Pointer pointer
Definition: btree.h:1482
void decrement()
Definition: btree.h:1523
bool operator!=(const const_iterator &x) const
Definition: btree.h:1535
typename Node::params_type params_type
Definition: btree.h:1462
typename params_type::pointer normal_pointer
Definition: btree.h:1467
bool operator==(const iterator &x) const
Definition: btree.h:1538
typename params_type::reference normal_reference
Definition: btree.h:1468
reference operator*() const
Definition: btree.h:1546
std::bidirectional_iterator_tag iterator_category
Definition: btree.h:1484
int position
Definition: btree.h:1595
btree_iterator operator++(int)
Definition: btree.h:1561
void increment()
Definition: btree.h:1515
typename params_type::const_pointer const_pointer
Definition: btree.h:1469
btree_iterator(Node *n, int p)
Definition: btree.h:1487
pointer operator->() const
Definition: btree.h:1549
btree_iterator< normal_node, normal_reference, normal_pointer > iterator
Definition: btree.h:1474
typename Node::key_type key_type
Definition: btree.h:1460
btree_iterator operator--(int)
Definition: btree.h:1566
void decrement_slow()
Definition: btree.h:2450
friend class base_checker
Definition: btree.h:1586
bool operator==(const const_iterator &x) const
Definition: btree.h:1532
btree_iterator< const_node, const_reference, const_pointer > const_iterator
Definition: btree.h:1476
typename params_type::value_type value_type
Definition: btree.h:1481
void increment_slow()
Definition: btree.h:2427
typename params_type::slot_type slot_type
Definition: btree.h:1471
slot_type * slot()
Definition: btree.h:1589
typename params_type::const_reference const_reference
Definition: btree.h:1470
btree_iterator()
Definition: btree.h:1486
btree_iterator & operator++()
Definition: btree.h:1553
typename Node::difference_type difference_type
Definition: btree.h:1480
typename Node::size_type size_type
Definition: btree.h:1461
const Node const_node
Definition: btree.h:1466
const value_type * const_pointer
Definition: btree.h:851
SlotPolicy slot_policy
Definition: btree.h:846
static void move(Alloc *alloc, slot_type *first, slot_type *last, slot_type *result)
Definition: btree.h:900
const value_type & const_reference
Definition: btree.h:853
ptrdiff_t difference_type
Definition: btree.h:841
btree_is_key_compare_to< key_compare, Key > is_key_compare_to
Definition: btree.h:836
Key key_type
Definition: btree.h:839
static void move(Alloc *alloc, slot_type *src, slot_type *dest)
Definition: btree.h:897
static void construct(Alloc *alloc, slot_type *slot, Args &&... args)
Definition: btree.h:881
Alloc allocator_type
Definition: btree.h:838
typename slot_policy::value_type value_type
Definition: btree.h:848
std::integral_constant< bool, Multi > is_multi_container
Definition: btree.h:844
static value_type & element(slot_type *slot)
Definition: btree.h:874
static void transfer(Alloc *alloc, slot_type *new_slot, slot_type *old_slot)
Definition: btree.h:890
typename key_compare_to_adapter< Compare >::type key_compare
Definition: btree.h:833
value_type * pointer
Definition: btree.h:850
static void swap(Alloc *alloc, slot_type *a, slot_type *b)
Definition: btree.h:894
phmap::conditional_t<(kNodeSlotSpace/sizeof(slot_type) >(std::numeric_limits< uint8_t >::max)()), uint16_t, uint8_t > node_count_type
Definition: btree.h:870
typename slot_policy::slot_type slot_type
Definition: btree.h:847
static void destroy(Alloc *alloc, slot_type *slot)
Definition: btree.h:887
@ kNodeSlotSpace
Definition: btree.h:861
@ kTargetNodeSize
Definition: btree.h:856
typename slot_policy::mutable_value_type init_type
Definition: btree.h:849
static const value_type & element(const slot_type *slot)
Definition: btree.h:877
std::size_t size_type
Definition: btree.h:840
value_type & reference
Definition: btree.h:852
static void construct(Alloc *alloc, slot_type *slot, slot_type *other)
Definition: btree.h:884
Compare type
Definition: btree.h:793
value_compare(const key_compare &cmp)
Definition: btree.h:925
auto operator()(const T &left, const U &right) const -> decltype(std::declval< key_compare >()(left.first, right.first))
Definition: btree.h:928
static const Key & key(const init_type &x)
Definition: btree.h:936
static const Key & key(const value_type &x)
Definition: btree.h:935
typename super_type::value_type value_type
Definition: btree.h:918
std::true_type is_map_container
Definition: btree.h:933
typename super_type::init_type init_type
Definition: btree.h:919
static mapped_type & value(value_type *value)
Definition: btree.h:938
typename super_type::slot_type slot_type
Definition: btree.h:917
Data mapped_type
Definition: btree.h:913
typename super_type::key_compare key_compare
Definition: btree.h:921
typename map_params::common_params super_type
Definition: btree.h:912
typename super_type::slot_policy slot_policy
Definition: btree.h:916
static const Key & key(const slot_type *x)
Definition: btree.h:937
static const Key & key(const slot_type *x)
Definition: btree.h:999
Key value_type
Definition: btree.h:993
typename set_params::common_params::slot_type slot_type
Definition: btree.h:994
typename set_params::common_params::key_compare value_compare
Definition: btree.h:995
std::false_type is_map_container
Definition: btree.h:996
static const Key & key(const value_type &x)
Definition: btree.h:998
static void swap(Alloc *, slot_type *a, slot_type *b)
Definition: btree.h:969
Key mutable_value_type
Definition: btree.h:947
static void move(Alloc *alloc, slot_type *first, slot_type *last, slot_type *result)
Definition: btree.h:980
static void move(Alloc *, slot_type *src, slot_type *dest)
Definition: btree.h:975
static const value_type & element(const slot_type *slot)
Definition: btree.h:950
static void construct(Alloc *alloc, slot_type *slot, Args &&... args)
Definition: btree.h:953
static void construct(Alloc *alloc, slot_type *slot, slot_type *other)
Definition: btree.h:959
Key value_type
Definition: btree.h:946
static void destroy(Alloc *alloc, slot_type *slot)
Definition: btree.h:964
Key slot_type
Definition: btree.h:945
static value_type & element(slot_type *slot)
Definition: btree.h:949
Compare comp
Definition: btree.h:1016
bool operator()(const K &a, const LK &b) const
Definition: btree.h:1010
upper_bound_adapter(const Compare &c)
Definition: btree.h:1008
Definition: phmap_base.h:95
Definition: phmap_base.h:134
T t
Definition: btree.h:97