Platform.Data.Doublets C++
Loading...
Searching...
No Matches
InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h
Go to the documentation of this file.
2{
3 template <typename TSelf, typename TLinksOptions>
5 : public Platform::Collections::Methods::Trees::RecursionlessSizeBalancedTreeMethods<
6 TSelf, typename TLinksOptions::LinkAddressType> /* public ILinksTreeMethods<TLinksOptions>, */
7 {
8 public:
9 using LinksOptionsType = TLinksOptions;
10 using LinkAddressType = typename LinksOptionsType::LinkAddressType;
11 using LinkType = typename LinksOptionsType::LinkType;
12 using WriteHandlerType = typename LinksOptionsType::WriteHandlerType;
13 using ReadHandlerType = typename LinksOptionsType::ReadHandlerType;
14
15 public:
16 static constexpr auto Constants = LinksOptionsType::Constants;
17
18 public:
20
21 public:
22 static constexpr LinkAddressType Continue = Constants.Continue;
23
24 public:
25 std::byte* LinksDataParts;
26
27 public:
28 std::byte* LinksIndexParts;
29
30 public:
31 std::byte* Header;
32
33 public:
34 InternalLinksRecursionlessSizeBalancedTreeMethodsBase(std::byte* linksDataParts, std::byte* linksIndexParts,
35 std::byte* header)
36 {
37 LinksDataParts = linksDataParts;
38 LinksIndexParts = linksIndexParts;
39 Header = header;
40 }
41
42 public:
44 {
45 return this->object().GetTreeRoot(linkAddress);
46 };
47
48 public:
50 {
51 return this->object().GetBasePartValue(link);
52 };
53
54 public:
56 {
57 return this->object().GetKeyPartValue(link);
58 };
59
60 public:
66
67 public:
73
74 public:
76 {
77 return this->GetKeyPartValue(first) < this->GetKeyPartValue(second);
78 }
79
80 public:
82 {
83 return this->GetKeyPartValue(first) > this->GetKeyPartValue(second);
84 }
85
86 public:
87 CArray<LinkAddressType> auto GetLinkValues(LinkAddressType linkIndex)
88 {
89 auto& link = GetLinkDataPartReference(linkIndex);
90 return LinkType{linkIndex, link.Source, link.Target};
91 }
92
93 public:
95 {
96 return this->object().Search(source, target);
97 };
98
99 public:
101 {
102 while (root != 0)
103 {
104 auto rootKey = this->GetKeyPartValue(root);
105 if (key < rootKey)
106 {
107 root = this->GetLeftOrDefault(root);
108 }
109 else if (key > rootKey)
110 {
111 root = this->GetRightOrDefault(root);
112 }
113 else
114 {
115 return root;
116 }
117 }
118 return 0;
119 }
120
121 public:
123 {
124 return this->GetSizeOrZero(this->GetTreeRoot(link));
125 }
126
127 public:
129 {
130 return this->EachUsageCore(base, this->GetTreeRoot(base), handler);
131 }
132
133 private:
134 LinkAddressType EachUsageCore(LinkAddressType base, LinkAddressType link, const ReadHandlerType& handler)
135 {
136 if (link == 0)
137 {
138 return Continue;
139 }
140 if ((this->EachUsageCore(base, this->GetLeftOrDefault(link), handler) == Break))
141 {
142 return Break;
143 }
144 if (handler(this->GetLinkValues(link)) == (Break))
145 {
146 return Break;
147 }
148 if ((this->EachUsageCore(base, this->GetRightOrDefault(link), handler) == Break))
149 {
150 return Break;
151 }
152 return Continue;
153 }
154 };
155} // namespace Platform::Data::Doublets::Memory::Split::Generic
static constexpr LinkAddressType Break
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:19
LinkAddressType SearchCore(LinkAddressType root, LinkAddressType key)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:100
LinkAddressType Search(LinkAddressType source, LinkAddressType target)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:94
std::byte * LinksIndexParts
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:28
std::byte * Header
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:31
std::byte * LinksDataParts
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:25
CArray< LinkAddressType > auto GetLinkValues(LinkAddressType linkIndex)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:87
LinkAddressType GetKeyPartValue(LinkAddressType link)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:55
LinkAddressType CountUsages(LinkAddressType link)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:122
typename LinksOptionsType::ReadHandlerType ReadHandlerType
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:13
TLinksOptions LinksOptionsType
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:9
LinkAddressType EachUsage(LinkAddressType base, const ReadHandlerType &handler)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:128
typename LinksOptionsType::LinkType LinkType
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:11
InternalLinksRecursionlessSizeBalancedTreeMethodsBase(std::byte *linksDataParts, std::byte *linksIndexParts, std::byte *header)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:34
LinkAddressType GetTreeRoot(LinkAddressType linkAddress)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:43
RawLinkIndexPart< LinkAddressType > & GetLinkIndexPartReference(LinkAddressType link)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:68
bool FirstIsToTheLeftOfSecond(LinkAddressType first, LinkAddressType second)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:75
bool FirstIsToTheRightOfSecond(LinkAddressType first, LinkAddressType second)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:81
typename LinksOptionsType::WriteHandlerType WriteHandlerType
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:12
static constexpr LinkAddressType Continue
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:22
typename LinksOptionsType::LinkAddressType LinkAddressType
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:10
LinkAddressType GetBasePartValue(LinkAddressType link)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:49
RawLinkDataPart< LinkAddressType > & GetLinkDataPartReference(LinkAddressType link)
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:61
static constexpr auto Constants
Definition InternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:16
Definition ExternalLinksRecursionlessSizeBalancedTreeMethodsBase.h:2