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