mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-30 09:00:38 +08:00
Add tests for btree and fix a couple issues.
This commit is contained in:
Vendored
+8
-8
@@ -1231,8 +1231,8 @@ namespace container_internal {
|
||||
|
||||
void set_parent(btree_node *p) { *GetField<0>() = p; }
|
||||
field_type &mutable_count() { return GetField<1>()[2]; }
|
||||
slot_type *slot(int i) { return &GetField<2>()[i]; }
|
||||
const slot_type *slot(int i) const { return &GetField<2>()[i]; }
|
||||
slot_type *slot(size_type i) { return &GetField<2>()[i]; }
|
||||
const slot_type *slot(size_type i) const { return &GetField<2>()[i]; }
|
||||
void set_position(field_type v) { GetField<1>()[0] = v; }
|
||||
void set_start(field_type v) { GetField<1>()[1] = v; }
|
||||
void set_count(field_type v) { GetField<1>()[2] = v; }
|
||||
@@ -1272,14 +1272,14 @@ namespace container_internal {
|
||||
}
|
||||
|
||||
// Getters for the key/value at position i in the node.
|
||||
const key_type &key(int i) const { return params_type::key(slot(i)); }
|
||||
reference value(int i) { return params_type::element(slot(i)); }
|
||||
const_reference value(int i) const { return params_type::element(slot(i)); }
|
||||
const key_type &key(size_type i) const { return params_type::key(slot(i)); }
|
||||
reference value(size_type i) { return params_type::element(slot(i)); }
|
||||
const_reference value(size_type i) const { return params_type::element(slot(i)); }
|
||||
|
||||
// Getters/setter for the child at position i in the node.
|
||||
btree_node *child(int i) const { return GetField<3>()[i]; }
|
||||
btree_node *&mutable_child(int i) { return GetField<3>()[i]; }
|
||||
void clear_child(int i) {
|
||||
btree_node *child(size_type i) const { return GetField<3>()[i]; }
|
||||
btree_node *&mutable_child(size_type i) { return GetField<3>()[i]; }
|
||||
void clear_child(size_type i) {
|
||||
phmap::container_internal::SanitizerPoisonObject(&mutable_child(i));
|
||||
}
|
||||
void set_child(int i, btree_node *c) {
|
||||
|
||||
Vendored
+19
-7
@@ -2874,6 +2874,18 @@ public:
|
||||
protected:
|
||||
friend struct CommonAccess;
|
||||
|
||||
struct transfer_tag_t {};
|
||||
node_handle_base(transfer_tag_t, const allocator_type& a, slot_type* s)
|
||||
: alloc_(a) {
|
||||
PolicyTraits::transfer(alloc(), slot(), s);
|
||||
}
|
||||
|
||||
struct move_tag_t {};
|
||||
node_handle_base(move_tag_t, const allocator_type& a, slot_type* s)
|
||||
: alloc_(a) {
|
||||
PolicyTraits::construct(alloc(), slot(), s);
|
||||
}
|
||||
|
||||
node_handle_base(const allocator_type& a, slot_type* s) : alloc_(a) {
|
||||
PolicyTraits::transfer(alloc(), slot(), s);
|
||||
}
|
||||
@@ -2923,7 +2935,7 @@ public:
|
||||
private:
|
||||
friend struct CommonAccess;
|
||||
|
||||
node_handle(const Alloc& a, typename Base::slot_type* s) : Base(a, s) {}
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
// For maps.
|
||||
@@ -2952,7 +2964,7 @@ public:
|
||||
private:
|
||||
friend struct CommonAccess;
|
||||
|
||||
node_handle(const Alloc& a, typename Base::slot_type* s) : Base(a, s) {}
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
// Provide access to non-public node-handle functions.
|
||||
@@ -2963,6 +2975,11 @@ struct CommonAccess
|
||||
return node.slot();
|
||||
}
|
||||
|
||||
template <typename Node>
|
||||
static void Destroy(Node* node) {
|
||||
node->destroy();
|
||||
}
|
||||
|
||||
template <typename Node>
|
||||
static void Reset(Node* node) {
|
||||
node->reset();
|
||||
@@ -2973,11 +2990,6 @@ struct CommonAccess
|
||||
return T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename Node>
|
||||
static void Destroy(Node* node) {
|
||||
node->destroy();
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
static T Transfer(Args&&... args) {
|
||||
return T(typename T::transfer_tag_t{}, std::forward<Args>(args)...);
|
||||
|
||||
Reference in New Issue
Block a user