annotate src/llrb/llrb.c @ 108:4db311ba1289

Set allocation size
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Tue, 12 Apr 2016 16:40:29 +0900
parents c13575c3dbe9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "llrbContext.h"
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "origin_cs.h"
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
5
65
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
6 extern void allocator(struct Context* context);
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
7 extern void compare(struct Context* context, struct Tree* tree, int key1, int key2);
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
8
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
9 extern int num;
19
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
11 __code put(struct Context* context, struct Tree* tree, struct Node* root, struct Allocate* allocate) {
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
12 allocate->size = sizeof(struct Node);
65
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
13 allocator(context);
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
14
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
15 stack_push(context->code_stack, &context->next);
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
16
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
17 context->next = StackClear;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
18 stack_push(context->code_stack, &context->next);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
19
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
20 tree->root = &context->data[context->dataNum]->node;
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
21
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
22 if (root) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
23 tree->current = root;
65
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
24 compare(context, tree, tree->current->key, context->data[Node]->node.key);
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
25
65
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
26 goto meta(context, Replace);
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
27 }
76
7ad6d1502a03 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
28
7ad6d1502a03 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
29 goto meta(context, Insert);
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
30 }
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
31
54
0299b90256e5 syntax suggest
kkb
parents: 53
diff changeset
32 __code put_stub(struct Context* context) {
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
33 goto put(context, &context->data[Tree]->tree, context->data[Tree]->tree.root, &context->data[Allocate]->allocate);
54
0299b90256e5 syntax suggest
kkb
parents: 53
diff changeset
34 }
0299b90256e5 syntax suggest
kkb
parents: 53
diff changeset
35
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
36 __code replaceNode(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode, int result) {
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
37 *newNode = *oldNode;
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
38 stack_push(context->node_stack, &newNode);
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
39
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
40 if (result == EQ) {
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
41 newNode->value = context->data[Node]->node.value;
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
42
80
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
43 stack_pop(context->code_stack, &context->next);
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
44 goto meta(context, context->next);
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
45 } else if (result == GT) {
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
46 tree->current = oldNode->right;
44
a0a58875c93f refactoring llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
47 newNode->right = context->heap;
31
dbbafae822f8 modify Non-Destructive Red Black Tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 27
diff changeset
48 } else {
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
49 tree->current = oldNode->left;
44
a0a58875c93f refactoring llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
50 newNode->left = context->heap;
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
51 }
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
52
108
4db311ba1289 Set allocation size
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
53 context->data[Allocate]->allocate.size = sizeof(struct Node);
65
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
54 allocator(context);
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
55
76
7ad6d1502a03 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
56 if (tree->current) {
65
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
57 compare(context, tree, tree->current->key, context->data[Node]->node.key);
025fd6e90597 to the function call(allocate and compare)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
58 goto meta(context, Replace);
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
59 }
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
60
76
7ad6d1502a03 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
61 goto meta(context, Insert);
19
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 }
9302b1a48008 add llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
64 __code replaceNode_stub(struct Context* context) {
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
65 goto replaceNode(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node, context->data[Tree]->tree.result);
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
66 }
23
868c2918b634 Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
67
80
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
68 __code insertNode(struct Context* context, struct Tree* tree, struct Node* node, struct Node* newNode) {
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
69 node->color = Red;
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
70 *newNode = *node;
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
71
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
72 tree->current = newNode;
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
73
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
74 goto meta(context, InsertCase1);
80
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
75 }
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
76
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
77 __code insertNode_stub(struct Context* context) {
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
78 goto insertNode(context, &context->data[Tree]->tree, &context->data[Node]->node, &context->data[context->dataNum]->node);
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
79 }
099d85f9d371 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
80
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
81 __code insertCase1(struct Context* context, struct Tree* tree, struct Node* current) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
82 if (!isEmpty(context->node_stack))
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
83 goto meta(context, InsertCase2);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
84
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
85 tree->root->color = Black;
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
86
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
87 stack_pop(context->code_stack, &context->next);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
88 goto meta(context, context->next);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
89 }
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
90
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
91 __code insert1_stub(struct Context* context) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
92 goto insertCase1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
93 }
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
94
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
95 __code insertCase2(struct Context* context, struct Node* current) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
96 struct Node* parent;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
97 stack_pop(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
98
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
99 if (parent->color == Black) {
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
100 stack_pop(context->code_stack, &context->next);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
101 goto meta(context, context->next);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
102 }
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
103
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
104 stack_push(context->node_stack, &parent);
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
105 goto meta(context, InsertCase3);
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
106 }
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
107
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
108 __code insert2_stub(struct Context* context) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
109 goto insertCase2(context, context->data[Tree]->tree.current);
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
110 }
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
111
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
112 __code insertCase3(struct Context* context, struct Tree* tree, struct Node* current) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
113 struct Node* parent;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
114 struct Node* uncle;
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
115 struct Node* grandparent;
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
116
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
117 stack_pop(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
118 stack_pop(context->node_stack, &grandparent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
119
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
120 if (grandparent->left == parent)
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
121 uncle = grandparent->right;
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
122 else
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
123 uncle = grandparent->left;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
124
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
125 if (uncle && (uncle->color == Red)) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
126 parent->color = Black;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
127 uncle->color = Black;
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
128 grandparent->color = Red;
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
129 tree->current = grandparent;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
130 goto meta(context, InsertCase1);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
131 }
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
132
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
133 stack_push(context->node_stack, &grandparent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
134 stack_push(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
135
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
136 goto meta(context, InsertCase4);
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
137 }
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
138
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
139 __code insert3_stub(struct Context* context) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
140 goto insertCase3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
141 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
142
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
143 __code insertCase4(struct Context* context, struct Tree* tree, struct Node* current) {
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
144 struct Node* parent;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
145 struct Node* grandparent;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
146
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
147 stack_pop(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
148 stack_pop(context->node_stack, &grandparent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
149
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
150 stack_push(context->node_stack, &grandparent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
151
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
152 tree->current = parent;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
153
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
154 if ((current == parent->right) && (parent == grandparent->left)) {
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
155 context->next = InsertCase4_1;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
156
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
157 stack_push(context->code_stack, &context->next);
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
158 goto meta(context, RotateL);
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
159 } else if ((current == parent->left) && (parent == grandparent->right)) {
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
160 context->next = InsertCase4_2;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
161
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
162 stack_push(context->code_stack, &context->next);
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
163 goto meta(context, RotateR);
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
164 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
165
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
166 stack_push(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
167 tree->current = current;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
168 goto meta(context, InsertCase5);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
169 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
170
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
171 __code insert4_stub(struct Context* context) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
172 goto insertCase4(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
173 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
174
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
175 __code insertCase4_1(struct Context* context, struct Tree* tree) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
176 stack_push(context->node_stack, &tree->current);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
177 tree->current = tree->current->left;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
178 goto meta(context, InsertCase5);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
179 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
180
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
181 __code insert4_1_stub(struct Context* context) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
182 goto insertCase4_1(context, &context->data[Tree]->tree);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
183 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
184
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
185 __code insertCase4_2(struct Context* context, struct Tree* tree) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
186 stack_push(context->node_stack, &tree->current);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
187 tree->current = tree->current->right;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
188 goto meta(context, InsertCase5);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
189 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
190
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
191 __code insert4_2_stub(struct Context* context) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
192 goto insertCase4_2(context, &context->data[Tree]->tree);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
193 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
194
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
195 __code insertCase5(struct Context* context, struct Tree* tree, struct Node* current) {
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
196 struct Node* parent;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
197 struct Node* grandparent;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
198
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
199 stack_pop(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
200 stack_pop(context->node_stack, &grandparent);
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
201
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
202 parent->color = Black;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
203 grandparent->color = Red;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
204
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
205 tree->current = grandparent;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
206
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
207 if ((current == parent->left) && (parent == grandparent->left))
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
208 goto meta(context, RotateR);
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
209 else
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
210 goto meta(context, RotateL);
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
211 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
212
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
213 __code insert5_stub(struct Context* context) {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
214 goto insertCase5(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
215 }
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
216
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
217 __code rotateLeft(struct Context* context, struct Node* node, struct Tree* tree) {
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
218 struct Node* tmp = node->right;
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
219 struct Node* parent = 0;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
220
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
221 stack_pop(context->node_stack, &parent);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
222
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
223 if (parent) {
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
224 if (node == parent->left)
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
225 parent->left = tmp;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
226 else
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
227 parent->right = tmp;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
228 } else {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
229 tree->root = tmp;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
230 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
231
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
232 stack_push(context->node_stack, &parent);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
233
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
234 node->right = tmp->left;
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
235 tmp->left = node;
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
236 tree->current = tmp;
20
324c44f2076f implement insert
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
237
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
238 stack_pop(context->code_stack, &context->next);
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
239 goto meta(context, context->next);
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
240 }
21
737a900518be implement insert
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 20
diff changeset
241
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
242 __code rotateLeft_stub(struct Context* context) {
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
243 goto rotateLeft(context, context->data[Tree]->tree.current, &context->data[Tree]->tree);
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
244 }
23
868c2918b634 Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
245
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
246 __code rotateRight(struct Context* context, struct Node* node, struct Tree* tree) {
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
247 struct Node* tmp = node->left;
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
248 struct Node* parent = 0;
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
249
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
250 stack_pop(context->node_stack, &parent);
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
251
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
252 if (parent) {
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
253 if (node == parent->left)
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
254 parent->left = tmp;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
255 else
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
256 parent->right = tmp;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
257 } else {
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
258 tree->root = tmp;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
259 }
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
260
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
261 stack_push(context->node_stack, &parent);
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
262
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
263 node->left = tmp->right;
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
264 tmp->right = node;
77
618c03f25108 implement insert(tail recursion)
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 76
diff changeset
265 tree->current = tmp;
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
266
72
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
267 stack_pop(context->code_stack, &context->next);
5c4b9d116eda use stack for code segment
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 69
diff changeset
268 goto meta(context, context->next);
24
7494c0b87ec4 implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
269 }
27
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 26
diff changeset
270
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
271 __code rotateRight_stub(struct Context* context) {
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
272 goto rotateRight(context, context->data[Tree]->tree.current, &context->data[Tree]->tree);
56
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
273 }
c469c5ed5b4d modify syntax
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
274
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
275 __code stackClear(struct Context* context, stack_ptr node_stack, struct Tree* tree) {
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
276 if (stack_pop(node_stack, &tree->current) == 0)
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
277 goto meta(context, StackClear);
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
278
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
279 tree->current = 0;
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
280
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
281 stack_pop(context->code_stack, &context->next);
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
282 goto meta(context, context->next);
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
283 }
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
284
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
285 __code stackClear_stub(struct Context* context) {
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
286 goto stackClear(context, context->node_stack, &context->data[Tree]->tree);
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
287 }
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
288
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
289
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
290 /* /\* __code get(struct Context* context, struct Tree* tree) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
291 /* /\* if (tree->root) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
292 /* /\* tree->current = tree->root; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
293
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
294 /* /\* goto meta(context, Search); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
295 /* /\* } *\/ */
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
296
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
297 /* /\* stack_pop(context->code_stack, &context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
298 /* /\* goto meta(context, context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
299 /* /\* } *\/ */
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
300
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
301 /* /\* __code get_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
302 /* /\* goto get(context, &context->data[Tree]->tree); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
303 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
304
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
305 /* /\* __code search(struct Context* context, struct Tree* tree, struct Node* node) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
306 /* /\* compare(context, tree, tree->current->key, node->key); *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
307
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
308 /* /\* if (tree->result == EQ) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
309 /* /\* *node = *tree->current; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
310
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
311 /* /\* goto meta(context, context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
312 /* /\* } else if (tree->result == GT) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
313 /* /\* tree->current = tree->current->right; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
314 /* /\* } else { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
315 /* /\* tree->current = tree->current->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
316 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
317
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
318 /* /\* if (tree->current) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
319 /* /\* goto meta(context, Search); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
320
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
321 /* /\* stack_pop(context->code_stack, &context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
322 /* /\* goto meta(context, context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
323 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
324
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
325 /* /\* __code search_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
326 /* /\* goto search(context, &context->data[Tree]->tree, &context->data[Node]->node); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
327 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
328
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
329 /* /\* __code delete(struct Context* context, struct Tree* tree) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
330 /* /\* if (tree->root) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
331 /* /\* stack_push(context->code_stack, &context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
332 /* /\* context->next = Delete1; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
333 /* /\* goto meta(context, Get); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
334 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
335
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
336 /* /\* goto meta(context, context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
337 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
338
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
339 /* /\* __code delete_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
340 /* /\* goto delete(context, &context->data[Tree]->tree); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
341 /* /\* } *\/ */
22
4c3c0ad4a75d add benchmark method
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 21
diff changeset
342
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
343 /* /\* __code delete1(struct Context* context, struct Tree* tree, struct Allocate* allocate) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
344 /* /\* allocate->size = sizeof(struct Node); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
345 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
346
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
347 /* /\* struct Node* root = tree->root; *\/ */
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
348
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
349 /* /\* tree->root = &context->data[context->dataNum]->node; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
350 /* /\* tree->current = root; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
351
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
352 /* /\* compare(context, tree, tree->current->key, context->data[Node]->node.key); *\/ */
76
7ad6d1502a03 refactoring
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 75
diff changeset
353
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
354 /* /\* goto meta(context, Replace_d1); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
355 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
356
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
357 /* /\* __code delete1_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
358 /* /\* goto delete1(context, &context->data[Tree]->tree, &context->data[Allocate]->allocate); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
359 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
360
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
361 /* /\* __code delete2(struct Context* context, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
362 /* /\* if (current->color == Black) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
363 /* /\* struct Node* child = current->right == NULL ? current->left : current->right; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
364 /* /\* current->color = child == NULL ? Black : child->color; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
365
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
366 /* /\* goto meta(context, DeleteCase1); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
367 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
368
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
369 /* /\* goto meta(context, Delete3); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
370 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
371
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
372 /* /\* __code delete2_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
373 /* /\* goto delete2(context, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
374 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
375
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
376 /* /\* __code delete3(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
377 /* /\* struct Node* tmp = current->right == NULL ? current->left : current->right; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
378
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
379 /* /\* if (current->parent) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
380 /* /\* if (current == current->parent->left) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
381 /* /\* current->parent->left = tmp; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
382 /* /\* else *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
383 /* /\* current->parent->right = tmp; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
384 /* /\* } else { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
385 /* /\* tree->root = tmp; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
386 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
387
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
388 /* /\* if (tmp) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
389 /* /\* tmp->parent = current->parent; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
390
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
391 /* /\* if (current->parent == NULL && tmp) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
392 /* /\* tmp->color = Black; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
393
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
394 /* /\* current == current->parent->left ? (current->parent->left = NULL) : (current->parent->right = NULL); *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
395
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
396 /* /\* stack_pop(context->code_stack, &context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
397 /* /\* goto meta(context, context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
398 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
399
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
400 /* /\* __code delete3_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
401 /* /\* goto delete3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
402 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
403
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
404 /* /\* __code replaceNodeForDelete1(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode, int result) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
405 /* /\* *newNode = *oldNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
406
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
407 /* /\* if (result == EQ) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
408 /* /\* goto meta(context, Replace_d2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
409 /* /\* else if (result == GT) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
410 /* /\* tree->current = newNode->right; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
411 /* /\* else *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
412 /* /\* tree->current = newNode->left; *\/ */
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
413
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
414 /* /\* tree->current->parent = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
415
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
416 /* /\* if (tree->current->left == NULL && tree->current->right == NULL) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
417 /* /\* goto meta(context, Delete2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
418
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
419 /* /\* if (result == GT) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
420 /* /\* newNode->right = context->heap; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
421 /* /\* else if (result == LT) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
422 /* /\* newNode->left = context->heap; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
423
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
424 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
425
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
426 /* /\* compare(context, tree, tree->current->key, context->data[Node]->node.key); *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
427
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
428 /* /\* goto meta(context, Replace_d1); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
429 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
430
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
431 /* /\* __code replaceNodeForDelete1_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
432 /* /\* goto replaceNodeForDelete1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node, context->data[Tree]->tree.result); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
433 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
434
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
435 /* /\* __code replaceNodeForDelete2(struct Context* context, struct Tree* tree, struct Node* newNode) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
436 /* /\* if (tree->current->left && tree->current->right) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
437 /* /\* newNode->left->parent = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
438 /* /\* tree->current = newNode->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
439 /* /\* newNode->left = context->heap; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
440 /* /\* tree->deleted = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
441
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
442 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
443 /* /\* tree->current->parent = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
444
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
445 /* /\* goto meta(context, FindMax1); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
446 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
447
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
448 /* /\* goto meta(context, Delete2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
449 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
450
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
451 /* /\* __code replaceNodeForDelete2_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
452 /* /\* goto replaceNodeForDelete2(context, &context->data[Tree]->tree, &context->data[context->dataNum]->node); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
453 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
454
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
455 /* /\* __code findMax1(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
456 /* /\* *newNode = *oldNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
457
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
458 /* /\* if (newNode->right) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
459 /* /\* goto meta(context, FindMax2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
460
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
461 /* /\* tree->deleted->key = newNode->key; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
462 /* /\* tree->deleted->value = newNode->value; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
463
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
464 /* /\* tree->current = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
465
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
466 /* /\* goto meta(context, Delete2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
467 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
468
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
469 /* /\* __code findMax1_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
470 /* /\* goto findMax1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
471 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
472
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
473
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
474 /* /\* __code findMax2(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
475 /* /\* *newNode = *oldNode; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
476
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
477 /* /\* if (newNode->right->right) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
478 /* /\* tree->current = newNode->right; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
479 /* /\* newNode->right = context->heap; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
480
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
481 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
482 /* /\* tree->current->parent = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
483
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
484 /* /\* goto meta(context, FindMax2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
485 /* /\* } *\/ */
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
486
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
487 /* /\* tree->deleted->key = newNode->right->key; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
488 /* /\* tree->deleted->value = newNode->right->value; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
489
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
490 /* /\* tree->current = newNode; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
491
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
492 /* /\* goto meta(context, Delete2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
493 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
494
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
495 /* /\* __code findMax2_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
496 /* /\* goto findMax2(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
497 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
498
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
499 /* /\* __code deleteCase1(struct Context* context, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
500 /* /\* if (current->parent) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
501 /* /\* goto meta(context, DeleteCase2); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
502
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
503 /* /\* goto meta(context, Delete3); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
504 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
505
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
506 /* /\* __code deleteCase1_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
507 /* /\* goto deleteCase1(context, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
508 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
509
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
510 /* /\* __code deleteCase2(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
511 /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
512
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
513 /* /\* if ((sibling == NULL ? Black : sibling->color) == Red) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
514 /* /\* current->parent->color = Red; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
515 /* /\* sibling->color = Black; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
516
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
517 /* /\* current == current->parent->left ? (current->parent->left = context->heap) : (current->parent->right = context->heap); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
518 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
519 /* /\* context->data[context->dataNum]->node = *sibling; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
520
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
521 /* /\* tree->current = current->parent; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
522
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
523 /* /\* context->next = DeleteCase3; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
524 /* /\* stack_push(context->code_stack, &context->next); *\/ */
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
525
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
526 /* /\* if (current == current->parent->left) *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
527 /* /\* goto meta(context, RotateL); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
528 /* /\* else *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
529 /* /\* goto meta(context, RotateR); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
530 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
531
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
532 /* /\* goto meta(context, DeleteCase3); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
533 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
534
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
535 /* /\* __code deleteCase2_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
536 /* /\* goto deleteCase2(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
537 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
538
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
539 /* /\* __code deleteCase3(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
540 /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
541
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
542 /* /\* if (current->parent->color == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
543 /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
544 /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
545 /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
546 /* /\* sibling->color = Red; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
547
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
548 /* /\* tree->current = current->parent; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
549 /* /\* goto meta(context, DeleteCase1); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
550 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
551
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
552 /* /\* goto meta(context, DeleteCase4); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
553 /* /\* } *\/ */
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
554
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
555 /* /\* __code deleteCase3_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
556 /* /\* goto deleteCase3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
557 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
558
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
559 /* /\* __code deleteCase4(struct Context* context, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
560 /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
561
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
562 /* /\* if (current->parent->color == Red && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
563 /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
564 /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
565 /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
566 /* /\* sibling->color = Red; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
567 /* /\* current->parent->color = Black; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
568
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
569 /* /\* goto meta(context, Delete3); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
570 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
571
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
572 /* /\* goto meta(context, DeleteCase5); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
573 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
574
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
575 /* /\* __code deleteCase4_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
576 /* /\* goto deleteCase4(context, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
577 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
578
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
579 /* /\* __code deleteCase5(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
580 /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
581 /* /\* sibling->parent = current->parent; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
582
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
583 /* /\* if (current == current->parent->left && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
584 /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
585 /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Red && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
586 /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
587 /* /\* sibling->color = Red; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
588 /* /\* sibling->left->color = Black; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
589
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
590 /* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
591 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
592 /* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
593 /* /\* *tmp = *sibling; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
594 /* /\* tmp->parent = current; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
595
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
596 /* /\* tmp->left = context->heap; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
597 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
598 /* /\* context->data[context->dataNum]->node = *sibling->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
599 /* /\* context->data[context->dataNum]->node.parent = tmp; *\/ */
69
368306e1bfed llrb deletion(not work).
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
600
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
601 /* /\* tree->current = tmp; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
602
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
603 /* /\* context->next = DeleteCase6; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
604 /* /\* stack_push(context->code_stack, &context->next); *\/ */
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
605
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
606 /* /\* goto meta(context, RotateR); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
607 /* /\* } else if (current == current->parent->right && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
608 /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
609 /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
610 /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Red) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
611 /* /\* sibling->color = Red; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
612 /* /\* sibling->right->color = Black; *\/ */
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
613
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
614 /* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
615 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
616 /* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
617 /* /\* *tmp = *sibling; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
618 /* /\* tmp->parent = current; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
619
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
620 /* /\* tmp->right = context->heap; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
621 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
622 /* /\* context->data[context->dataNum]->node = *sibling->right; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
623 /* /\* context->data[context->dataNum]->node.parent = tmp; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
624
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
625 /* /\* tree->current = tmp; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
626
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
627 /* /\* context->next = DeleteCase6; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
628 /* /\* stack_push(context->code_stack, &context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
629 /* /\* goto meta(context, RotateL); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
630 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
631
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
632 /* /\* goto meta(context, DeleteCase6); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
633 /* /\* } *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
634
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
635 /* /\* __code deleteCase5_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
636 /* /\* goto deleteCase5(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
637 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
638
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
639 /* /\* __code deleteCase6(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
640 /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
641
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
642 /* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
643 /* /\* allocator(context); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
644 /* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
645 /* /\* *tmp = *sibling; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
646 /* /\* tmp->parent = current; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
647
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
648 /* /\* tmp->color = current->parent->color; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
649 /* /\* current->parent->color = Black; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
650
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
651 /* /\* context->next = Delete3; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
652 /* /\* stack_push(context->code_stack, &context->next); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
653
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
654 /* /\* if (current == current->parent->left) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
655 /* /\* tmp->right->color = Black; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
656 /* /\* tree->current = current->parent; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
657
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
658 /* /\* goto meta(context, RotateL); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
659 /* /\* } else { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
660 /* /\* tmp->left->color = Black; *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
661 /* /\* tree->current = current->parent; *\/ */
81
dc6f665bb753 implement delete(tail call). do not work
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
662
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
663 /* /\* goto meta(context, RotateR); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
664 /* /\* } *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
665 /* /\* } *\/ */
73
2667c3251a00 implement llrb deletion
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 72
diff changeset
666
83
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
667 /* /\* __code deleteCase6_stub(struct Context* context) { *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
668 /* /\* goto deleteCase6(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
c13575c3dbe9 use stack
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
669 /* /\* } *\/ */