7
|
1 __code getMinHeight_stub(struct Context* context) {
|
|
2 goto getMinHeight(context, &context->data[Allocate]->allocate, &context->data[AkashaInfo]->akashaInfo);
|
|
3 }
|
|
4
|
|
5 __code getMinHeight(struct Context* context, struct Allocate* allocate, struct AkashaInfo* akashaInfo) {
|
|
6 const struct AkashaNode* akashaNode = akashaInfo->akashaNode;
|
|
7
|
|
8 if (akashaNode == NULL) {
|
|
9 allocate->size = sizeof(struct AkashaNode);
|
|
10 allocator(context);
|
|
11 akashaInfo->akashaNode = (struct AkashaNode*)context->data[context->dataNum];
|
|
12
|
|
13 akashaInfo->akashaNode->height = 1;
|
|
14 akashaInfo->akashaNode->node = context->data[Tree]->tree.root;
|
|
15
|
|
16 goto getMaxHeight_stub(context);
|
|
17 }
|
|
18
|
|
19 const struct Node* node = akashaInfo->akashaNode->node;
|
|
20 if (node->left == NULL && node->right == NULL) {
|
|
21 if (akashaInfo->minHeight > akashaNode->height) {
|
|
22 akashaInfo->minHeight = akashaNode->height;
|
|
23 akashaInfo->akashaNode = akashaNode->nextAkashaNode;
|
|
24 goto getMinHeight_stub(context);
|
|
25 }
|
|
26 }
|
|
27
|
|
28 akashaInfo->akashaNode = akashaInfo->akashaNode->nextAkashaNode;
|
|
29
|
|
30 if (node->left != NULL) {
|
|
31 allocate->size = sizeof(struct AkashaNode);
|
|
32 allocator(context);
|
|
33 struct AkashaNode* left = (struct AkashaNode*)context->data[context->dataNum];
|
|
34 left->height = akashaNode->height+1;
|
|
35 left->node = node->left;
|
|
36 left->nextAkashaNode = akashaInfo->akashaNode;
|
|
37 akashaInfo->akashaNode = left;
|
|
38 }
|
|
39
|
|
40 if (node->right != NULL) {
|
|
41 allocate->size = sizeof(struct AkashaNode);
|
|
42 allocator(context);
|
|
43 struct AkashaNode* right = (struct AkashaNode*)context->data[context->dataNum];
|
|
44 right->height = akashaNode->height+1;
|
|
45 right->node = node->right;
|
|
46 right->nextAkashaNode = akashaInfo->akashaNode;
|
|
47 akashaInfo->akashaNode = right;
|
|
48 }
|
|
49
|
|
50 goto getMinHeight_stub(context);
|
|
51 }
|