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