1717#ifndef PHTREE_V16_ENTRY_H
1818#define PHTREE_V16_ENTRY_H
1919
20- #include " node.h"
2120#include " ../../phtree/common/common.h"
21+ #include " node.h"
2222#include < cassert>
2323#include < cstdint>
2424#include < memory>
@@ -39,56 +39,57 @@ class Node;
3939 */
4040template <dimension_t DIM, typename T, typename SCALAR>
4141class Entry {
42- using Key = PhPoint<DIM, SCALAR>;
43- using Value = std::remove_const_t <T>;
44- using Node = Node<DIM, T, SCALAR>;
42+ using KeyT = PhPoint<DIM, SCALAR>;
43+ using ValueT = std::remove_const_t <T>;
44+ using NodeT = Node<DIM, T, SCALAR>;
4545
4646 public:
47- Entry () : kd_key_(), value_{std::in_place_type<Value >, T{}} {}
47+ Entry () : kd_key_(), value_{std::in_place_type<ValueT >, T{}} {}
4848
4949 /*
5050 * Construct entry with existing node.
5151 */
52- Entry (const Key & k, std::unique_ptr<Node >&& node)
52+ Entry (const KeyT & k, std::unique_ptr<NodeT >&& node)
5353 : kd_key_{k}
54- , value_{std::in_place_type<std::unique_ptr<Node>>, std::forward<std::unique_ptr<Node>>(node)} {
55- }
54+ , value_{
55+ std::in_place_type<std::unique_ptr<NodeT>>, std::forward<std::unique_ptr<NodeT>>(node)} { }
5656
5757 /*
5858 * Construct entry with a new node.
5959 */
6060 Entry (bit_width_t infix_len, bit_width_t postfix_len)
6161 : kd_key_()
62- , value_{std::in_place_type<std::unique_ptr<Node>>,
63- std::make_unique<Node>(infix_len, postfix_len)} {}
62+ , value_{
63+ std::in_place_type<std::unique_ptr<NodeT>>,
64+ std::make_unique<NodeT>(infix_len, postfix_len)} {}
6465
6566 /*
6667 * Construct entry with new T or moved T.
6768 */
6869 template <typename ... _Args>
69- explicit Entry (const Key & k, _Args&&... __args)
70- : kd_key_{k}, value_{std::in_place_type<Value >, std::forward<_Args>(__args)...} {}
70+ explicit Entry (const KeyT & k, _Args&&... __args)
71+ : kd_key_{k}, value_{std::in_place_type<ValueT >, std::forward<_Args>(__args)...} {}
7172
72- [[nodiscard]] const Key & GetKey () const {
73+ [[nodiscard]] const KeyT & GetKey () const {
7374 return kd_key_;
7475 }
7576
7677 [[nodiscard]] bool IsValue () const {
77- return std::holds_alternative<Value >(value_);
78+ return std::holds_alternative<ValueT >(value_);
7879 }
7980
8081 [[nodiscard]] bool IsNode () const {
81- return std::holds_alternative<std::unique_ptr<Node >>(value_);
82+ return std::holds_alternative<std::unique_ptr<NodeT >>(value_);
8283 }
8384
8485 [[nodiscard]] T& GetValue () const {
8586 assert (IsValue ());
86- return const_cast <T&>(std::get<Value >(value_));
87+ return const_cast <T&>(std::get<ValueT >(value_));
8788 }
8889
89- [[nodiscard]] Node & GetNode () const {
90+ [[nodiscard]] NodeT & GetNode () const {
9091 assert (IsNode ());
91- return *std::get<std::unique_ptr<Node >>(value_);
92+ return *std::get<std::unique_ptr<NodeT >>(value_);
9293 }
9394
9495 void ReplaceNodeWithDataFromEntry (Entry&& other) {
@@ -98,14 +99,14 @@ class Entry {
9899 // 'value_' points indirectly to 'entry' so we have to remove `entity's` content before
99100 // assigning anything to `value_` here. Otherwise the assignment would destruct the previous
100101 // content and, by reachability, `entity's` content.
101- auto old_node = std::get<std::unique_ptr<Node >>(value_).release ();
102+ auto old_node = std::get<std::unique_ptr<NodeT >>(value_).release ();
102103 value_ = std::move (other.value_ );
103104 delete old_node;
104105 }
105106
106107 private:
107- Key kd_key_;
108- std::variant<Value , std::unique_ptr<Node >> value_;
108+ KeyT kd_key_;
109+ std::variant<ValueT , std::unique_ptr<NodeT >> value_;
109110};
110111} // namespace improbable::phtree::v16
111112
0 commit comments