Platform.Data.Doublets C++
Loading...
Searching...
No Matches
LinksTargetsAvlBalancedTreeMethods.h
Go to the documentation of this file.
2{
3 template <typename TLinksOptions>
5 : public LinksAvlBalancedTreeMethodsBase<LinksTargetsAvlBalancedTreeMethods<TLinksOptions>, TLinksOptions>
6 {
10 using typename base::LinkAddressType;
11 using typename base::LinkType;
12 using typename base::ReadHandlerType;
13
14 public:
15 LinksTargetsAvlBalancedTreeMethods(std::byte* storage, std::byte* header) : base(storage, header) {}
16
17 public:
19 {
20 return &this->GetLinkReference(node).LeftAsTarget;
21 }
22
23 public:
25 {
26 return &this->GetLinkReference(node).RightAsTarget;
27 }
28
29 public:
31 {
32 return this->GetLinkReference(node).LeftAsTarget;
33 }
34
35 public:
37 {
38 return this->GetLinkReference(node).RightAsTarget;
39 }
40
41 public:
43 {
44 this->GetLinkReference(node).LeftAsTarget = left;
45 }
46
47 public:
49 {
50 this->GetLinkReference(node).RightAsTarget = right;
51 }
52
53 public:
55 {
56 return this->GetSizeValue(this->GetLinkReference(node).SizeAsTarget);
57 }
58
59 public:
61 {
62 this->SetSizeValue(&this->GetLinkReference(node).SizeAsTarget, size);
63 }
64
65 public:
67 {
68 return this->GetLeftIsChildValue(this->GetLinkReference(node).SizeAsTarget);
69 }
70
71 public:
72 void SetLeftIsChild(LinkAddressType node, bool value)
73 {
74 this->SetLeftIsChildValue(&this->GetLinkReference(node).SizeAsTarget, value);
75 }
76
77 public:
79 {
80 return this->GetRightIsChildValue(this->GetLinkReference(node).SizeAsTarget);
81 }
82
83 public:
84 void SetRightIsChild(LinkAddressType node, bool value)
85 {
86 this->SetRightIsChildValue(&this->GetLinkReference(node).SizeAsTarget, value);
87 }
88
89 public:
91 {
92 return this->GetBalanceValue(this->GetLinkReference(node).SizeAsTarget);
93 }
94
95 public:
96 void SetBalance(LinkAddressType node, int8_t value)
97 {
98 this->SetBalanceValue(&this->GetLinkReference(node).SizeAsTarget, value);
99 }
100
101 public:
103 {
104 return this->GetHeaderReference().RootAsTarget;
105 }
106
107 public:
109 {
110 return this->GetLinkReference(linkAddress).Target;
111 }
112
113 public:
115 LinkAddressType secondSource, LinkAddressType secondTarget)
116 {
117 return (firstTarget < secondTarget) || (firstTarget == secondTarget && firstSource < secondSource);
118 }
119
120 public:
122 LinkAddressType secondSource, LinkAddressType secondTarget)
123 {
124 return (firstTarget > secondTarget) || (firstTarget == secondTarget && firstSource > secondSource);
125 }
126
127 public:
129 {
130 auto& link = this->GetLinkReference(node);
131 link.LeftAsTarget = 0;
132 link.RightAsTarget = 0;
133 link.SizeAsTarget = 0;
134 }
135
136 public:
137 // Intentional CRTP customization of the base tree algorithm.
138 // cppcheck-suppress duplInheritedMember
143
144 // Intentional CRTP customization of the base tree algorithm.
145 // cppcheck-suppress duplInheritedMember
147 {
148 return base::Search(source, target);
149 }
150
151 LinkAddressType EachUsage(LinkAddressType root, const std::function<LinkAddressType(const LinkType&)>& handler)
152 {
153 return base::EachUsage(root, handler);
154 }
155
157 {
158 base::methods::Detach(&root, linkIndex);
159 }
160
162 {
163 base::methods::Attach(&root, linkIndex);
164 }
165 };
166} // namespace Platform::Data::Doublets::Memory::United::Generic
Definition LinksAvlBalancedTreeMethodsBase.h:2
void SetSizeValue(LinkAddressType *storedValue, LinkAddressType size)
Definition LinksAvlBalancedTreeMethodsBase.h:211
LinkAddressType EachUsage(LinkAddressType link, std::function< LinkAddressType(LinkType)> handler)
Definition LinksAvlBalancedTreeMethodsBase.h:124
bool FirstIsToTheRightOfSecond(LinkAddressType first, LinkAddressType second)
Definition LinksAvlBalancedTreeMethodsBase.h:196
void SetBalanceValue(LinkAddressType *storedValue, std::int8_t value)
Definition LinksAvlBalancedTreeMethodsBase.h:273
LinkAddressType Search(LinkAddressType source, LinkAddressType target)
Definition LinksAvlBalancedTreeMethodsBase.h:61
bool FirstIsToTheLeftOfSecond(LinkAddressType first, LinkAddressType second)
Definition LinksAvlBalancedTreeMethodsBase.h:187
LinksTargetsAvlBalancedTreeMethods(std::byte *storage, std::byte *header)
Definition LinksTargetsAvlBalancedTreeMethods.h:15
void ClearNode(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:128
void Detach(LinkAddressType &root, LinkAddressType linkIndex)
Definition LinksTargetsAvlBalancedTreeMethods.h:156
void SetLeftIsChild(LinkAddressType node, bool value)
Definition LinksTargetsAvlBalancedTreeMethods.h:72
LinkAddressType CountUsages(LinkAddressType root)
Definition LinksTargetsAvlBalancedTreeMethods.h:139
LinkAddressType EachUsage(LinkAddressType root, const std::function< LinkAddressType(const LinkType &)> &handler)
Definition LinksTargetsAvlBalancedTreeMethods.h:151
LinkAddressType GetRight(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:36
LinkAddressType Search(LinkAddressType source, LinkAddressType target)
Definition LinksTargetsAvlBalancedTreeMethods.h:146
LinkAddressType GetSize(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:54
void SetRightIsChild(LinkAddressType node, bool value)
Definition LinksTargetsAvlBalancedTreeMethods.h:84
LinkAddressType GetTreeRoot()
Definition LinksTargetsAvlBalancedTreeMethods.h:102
void SetBalance(LinkAddressType node, int8_t value)
Definition LinksTargetsAvlBalancedTreeMethods.h:96
int8_t GetBalance(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:90
void Attach(LinkAddressType &root, LinkAddressType linkIndex)
Definition LinksTargetsAvlBalancedTreeMethods.h:161
void SetSize(LinkAddressType node, LinkAddressType size)
Definition LinksTargetsAvlBalancedTreeMethods.h:60
bool GetRightIsChild(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:78
LinkAddressType * GetLeftReference(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:18
LinkAddressType * GetRightReference(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:24
LinkAddressType GetBasePartValue(LinkAddressType linkAddress)
Definition LinksTargetsAvlBalancedTreeMethods.h:108
void SetLeft(LinkAddressType node, LinkAddressType left)
Definition LinksTargetsAvlBalancedTreeMethods.h:42
bool FirstIsToTheRightOfSecond(LinkAddressType firstSource, LinkAddressType firstTarget, LinkAddressType secondSource, LinkAddressType secondTarget)
Definition LinksTargetsAvlBalancedTreeMethods.h:121
void SetRight(LinkAddressType node, LinkAddressType right)
Definition LinksTargetsAvlBalancedTreeMethods.h:48
LinkAddressType GetLeft(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:30
bool GetLeftIsChild(LinkAddressType node)
Definition LinksTargetsAvlBalancedTreeMethods.h:66
bool FirstIsToTheLeftOfSecond(LinkAddressType firstSource, LinkAddressType firstTarget, LinkAddressType secondSource, LinkAddressType secondTarget)
Definition LinksTargetsAvlBalancedTreeMethods.h:114