Platform.Data.Doublets C++
Loading...
Searching...
No Matches
LinksSourcesAvlBalancedTreeMethods.h
Go to the documentation of this file.
2{
3 template <typename TLinksOptions>
5 : public LinksAvlBalancedTreeMethodsBase<LinksSourcesAvlBalancedTreeMethods<TLinksOptions>, TLinksOptions>
6 {
10 using typename base::LinkAddressType;
11 using typename base::LinkType;
12 using typename base::ReadHandlerType;
13
14 public:
15 LinksSourcesAvlBalancedTreeMethods(std::byte* storage, std::byte* header) : base(storage, header) {}
16
17 public:
19 {
20 return &this->GetLinkReference(node).LeftAsSource;
21 }
22
23 public:
25 {
26 return &this->GetLinkReference(node).RightAsSource;
27 }
28
29 public:
31 {
32 return this->GetLinkReference(node).LeftAsSource;
33 }
34
35 public:
37 {
38 return this->GetLinkReference(node).RightAsSource;
39 }
40
41 public:
43 {
44 this->GetLinkReference(node).LeftAsSource = left;
45 }
46
47 public:
49 {
50 this->GetLinkReference(node).RightAsSource = right;
51 }
52
53 public:
55 {
56 return this->GetSizeValue(this->GetLinkReference(node).SizeAsSource);
57 }
58
59 public:
61 {
62 this->SetSizeValue(&this->GetLinkReference(node).SizeAsSource, size);
63 }
64
65 public:
67 {
68 return this->GetLeftIsChildValue(this->GetLinkReference(node).SizeAsSource);
69 }
70
71 public:
72 void SetLeftIsChild(LinkAddressType node, bool value)
73 {
74 this->SetLeftIsChildValue(&this->GetLinkReference(node).SizeAsSource, value);
75 }
76
77 public:
79 {
80 return this->GetRightIsChildValue(this->GetLinkReference(node).SizeAsSource);
81 }
82
83 public:
84 void SetRightIsChild(LinkAddressType node, bool value)
85 {
86 this->SetRightIsChildValue(&this->GetLinkReference(node).SizeAsSource, value);
87 }
88
89 public:
91 {
92 return this->GetBalanceValue(this->GetLinkReference(node).SizeAsSource);
93 }
94
95 public:
96 void SetBalance(LinkAddressType node, int8_t value)
97 {
98 this->SetBalanceValue(&this->GetLinkReference(node).SizeAsSource, value);
99 }
100
101 public:
103 {
104 return this->GetHeaderReference().RootAsSource;
105 }
106
107 public:
109 {
110 return this->GetLinkReference(linkAddress).Source;
111 }
112
113 public:
115 LinkAddressType secondSource, LinkAddressType secondTarget)
116 {
117 return (firstSource < secondSource) || (firstSource == secondSource && firstTarget < secondTarget);
118 }
119
120 public:
122 LinkAddressType secondSource, LinkAddressType secondTarget)
123 {
124 return firstSource > secondSource || (firstSource == secondSource && firstTarget > secondTarget);
125 }
126
127 public:
129 {
130 auto& link = this->GetLinkReference(node);
131 link.LeftAsSource = 0;
132 link.RightAsSource = 0;
133 link.SizeAsSource = 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
bool GetLeftIsChild(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:66
void Attach(LinkAddressType &root, LinkAddressType linkIndex)
Definition LinksSourcesAvlBalancedTreeMethods.h:161
LinkAddressType CountUsages(LinkAddressType root)
Definition LinksSourcesAvlBalancedTreeMethods.h:139
LinkAddressType * GetLeftReference(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:18
void SetRight(LinkAddressType node, LinkAddressType right)
Definition LinksSourcesAvlBalancedTreeMethods.h:48
bool FirstIsToTheRightOfSecond(LinkAddressType firstSource, LinkAddressType firstTarget, LinkAddressType secondSource, LinkAddressType secondTarget)
Definition LinksSourcesAvlBalancedTreeMethods.h:121
void SetLeftIsChild(LinkAddressType node, bool value)
Definition LinksSourcesAvlBalancedTreeMethods.h:72
void SetLeft(LinkAddressType node, LinkAddressType left)
Definition LinksSourcesAvlBalancedTreeMethods.h:42
LinkAddressType Search(LinkAddressType source, LinkAddressType target)
Definition LinksSourcesAvlBalancedTreeMethods.h:146
int8_t GetBalance(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:90
void Detach(LinkAddressType &root, LinkAddressType linkIndex)
Definition LinksSourcesAvlBalancedTreeMethods.h:156
void SetRightIsChild(LinkAddressType node, bool value)
Definition LinksSourcesAvlBalancedTreeMethods.h:84
LinkAddressType GetSize(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:54
void ClearNode(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:128
LinkAddressType GetBasePartValue(LinkAddressType linkAddress)
Definition LinksSourcesAvlBalancedTreeMethods.h:108
bool GetRightIsChild(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:78
LinkAddressType GetRight(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:36
LinkAddressType EachUsage(LinkAddressType root, const std::function< LinkAddressType(const LinkType &)> &handler)
Definition LinksSourcesAvlBalancedTreeMethods.h:151
LinkAddressType * GetRightReference(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:24
LinksSourcesAvlBalancedTreeMethods(std::byte *storage, std::byte *header)
Definition LinksSourcesAvlBalancedTreeMethods.h:15
void SetBalance(LinkAddressType node, int8_t value)
Definition LinksSourcesAvlBalancedTreeMethods.h:96
void SetSize(LinkAddressType node, LinkAddressType size)
Definition LinksSourcesAvlBalancedTreeMethods.h:60
LinkAddressType GetLeft(LinkAddressType node)
Definition LinksSourcesAvlBalancedTreeMethods.h:30
bool FirstIsToTheLeftOfSecond(LinkAddressType firstSource, LinkAddressType firstTarget, LinkAddressType secondSource, LinkAddressType secondTarget)
Definition LinksSourcesAvlBalancedTreeMethods.h:114
LinkAddressType GetTreeRoot()
Definition LinksSourcesAvlBalancedTreeMethods.h:102