Mercurial > hg > Gears > GearsAgda
comparison src/llrb/llrbContext.c @ 81:dc6f665bb753
implement delete(tail call). do not work
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 11 Dec 2015 15:06:20 +0900 |
parents | 618c03f25108 |
children | c13575c3dbe9 |
comparison
equal
deleted
inserted
replaced
80:099d85f9d371 | 81:dc6f665bb753 |
---|---|
17 extern __code rotateLeft_stub(struct Context*); | 17 extern __code rotateLeft_stub(struct Context*); |
18 extern __code rotateRight_stub(struct Context*); | 18 extern __code rotateRight_stub(struct Context*); |
19 extern __code colorFlip_stub(struct Context*); | 19 extern __code colorFlip_stub(struct Context*); |
20 extern __code fixUp_stub(struct Context*); | 20 extern __code fixUp_stub(struct Context*); |
21 extern __code changeReference_stub(struct Context*); | 21 extern __code changeReference_stub(struct Context*); |
22 extern __code balance1_stub(struct Context*); | 22 extern __code insert1_stub(struct Context*); |
23 extern __code balance2_stub(struct Context*); | 23 extern __code insert2_stub(struct Context*); |
24 extern __code balance3_stub(struct Context*); | 24 extern __code insert3_stub(struct Context*); |
25 extern __code balance4_stub(struct Context*); | 25 extern __code insert4_stub(struct Context*); |
26 extern __code balance4_1_stub(struct Context*); | 26 extern __code insert4_1_stub(struct Context*); |
27 extern __code balance4_2_stub(struct Context*); | 27 extern __code insert4_2_stub(struct Context*); |
28 extern __code balance5_stub(struct Context*); | 28 extern __code insert5_stub(struct Context*); |
29 extern __code setRoot_stub(struct Context*); | 29 extern __code insert5_1_stub(struct Context*); |
30 extern __code get_stub(struct Context*); | 30 extern __code get_stub(struct Context*); |
31 extern __code findMin_stub(struct Context*); | 31 extern __code search_stub(struct Context*); |
32 extern __code delete_stub(struct Context*); | 32 extern __code delete_stub(struct Context*); |
33 extern __code replaceNode_d1_stub(struct Context*); | 33 extern __code delete1_stub(struct Context*); |
34 extern __code replaceNode_d2_stub(struct Context*); | 34 extern __code delete2_stub(struct Context*); |
35 extern __code replaceNode_d3_stub(struct Context*); | 35 extern __code delete3_stub(struct Context*); |
36 extern __code replaceNode_d4_stub(struct Context*); | 36 extern __code replaceNodeForDelete1_stub(struct Context*); |
37 extern __code moveRedLeft1_stub(struct Context*); | 37 extern __code replaceNodeForDelete2_stub(struct Context*); |
38 extern __code moveRedLeft2_stub(struct Context*); | 38 extern __code findMax1_stub(struct Context*); |
39 extern __code moveRedLeft3_stub(struct Context*); | 39 extern __code findMax2_stub(struct Context*); |
40 extern __code moveRedRight1_stub(struct Context*); | 40 extern __code deleteCase1_stub(struct Context*); |
41 extern __code moveRedRight2_stub(struct Context*); | 41 extern __code deleteCase2_stub(struct Context*); |
42 extern __code deleteMin1_stub(struct Context*); | 42 extern __code deleteCase3_stub(struct Context*); |
43 extern __code deleteMin2_stub(struct Context*); | 43 extern __code deleteCase4_stub(struct Context*); |
44 extern __code deleteCase5_stub(struct Context*); | |
45 extern __code deleteCase6_stub(struct Context*); | |
44 extern __code exit_code(struct Context*); | 46 extern __code exit_code(struct Context*); |
45 | 47 |
46 __code initLLRBContext(struct Context* context, int num) { | 48 __code initLLRBContext(struct Context* context, int num) { |
47 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; | 49 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; |
48 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); | 50 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); |
62 context->code[Put] = put_stub; | 64 context->code[Put] = put_stub; |
63 context->code[Replace] = replaceNode_stub; | 65 context->code[Replace] = replaceNode_stub; |
64 context->code[Insert] = insertNode_stub; | 66 context->code[Insert] = insertNode_stub; |
65 context->code[RotateL] = rotateLeft_stub; | 67 context->code[RotateL] = rotateLeft_stub; |
66 context->code[RotateR] = rotateRight_stub; | 68 context->code[RotateR] = rotateRight_stub; |
67 context->code[ColorFlip] = colorFlip_stub; | 69 context->code[InsertCase1] = insert1_stub; |
68 context->code[FixUp] = fixUp_stub; | 70 context->code[InsertCase2] = insert2_stub; |
69 context->code[ChangeRef] = changeReference_stub; | 71 context->code[InsertCase3] = insert3_stub; |
70 context->code[Balance1] = balance1_stub; | 72 context->code[InsertCase4] = insert4_stub; |
71 context->code[Balance2] = balance2_stub; | 73 context->code[InsertCase4_1] = insert4_1_stub; |
72 context->code[Balance3] = balance3_stub; | 74 context->code[InsertCase4_2] = insert4_2_stub; |
73 context->code[Balance4] = balance4_stub; | 75 context->code[InsertCase5] = insert5_stub; |
74 context->code[Balance4_1] = balance4_1_stub; | 76 context->code[InsertCase5_1] = insert5_1_stub; |
75 context->code[Balance4_2] = balance4_2_stub; | |
76 context->code[Balance5] = balance5_stub; | |
77 context->code[SetRoot] = setRoot_stub; | |
78 context->code[Get] = get_stub; | 77 context->code[Get] = get_stub; |
79 context->code[Delete] = delete_stub; | 78 context->code[Search] = search_stub; |
80 context->code[FindMin] = findMin_stub; | 79 context->code[Delete] = delete_stub; |
81 context->code[Replace_d1] = replaceNode_d1_stub; | 80 context->code[Delete1] = delete1_stub; |
82 context->code[Replace_d2] = replaceNode_d2_stub; | 81 context->code[Delete2] = delete2_stub; |
83 context->code[Replace_d3] = replaceNode_d3_stub; | 82 context->code[Delete3] = delete3_stub; |
84 context->code[Replace_d4] = replaceNode_d4_stub; | 83 context->code[Replace_d1] = replaceNodeForDelete1_stub; |
85 context->code[MoveRedL1] = moveRedLeft1_stub; | 84 context->code[Replace_d2] = replaceNodeForDelete2_stub; |
86 context->code[MoveRedL2] = moveRedLeft2_stub; | 85 context->code[FindMax1] = findMax1_stub; |
87 context->code[MoveRedL3] = moveRedLeft3_stub; | 86 context->code[FindMax2] = findMax2_stub; |
88 context->code[MoveRedR1] = moveRedRight1_stub; | 87 context->code[DeleteCase1] = deleteCase1_stub; |
89 context->code[MoveRedR2] = moveRedRight2_stub; | 88 context->code[DeleteCase2] = deleteCase2_stub; |
90 context->code[DeleteMin1] = deleteMin1_stub; | 89 context->code[DeleteCase3] = deleteCase3_stub; |
91 context->code[DeleteMin2] = deleteMin2_stub; | 90 context->code[DeleteCase4] = deleteCase4_stub; |
91 context->code[DeleteCase5] = deleteCase5_stub; | |
92 context->code[DeleteCase6] = deleteCase6_stub; | |
92 context->code[Exit] = exit_code; | 93 context->code[Exit] = exit_code; |
93 | 94 |
94 context->heap = context->heapStart; | 95 context->heap = context->heapStart; |
95 | 96 |
96 context->data[Allocate] = context->heap; | 97 context->data[Allocate] = context->heap; |
105 context->dataNum = Node; | 106 context->dataNum = Node; |
106 | 107 |
107 struct Tree* tree = &context->data[Tree]->tree; | 108 struct Tree* tree = &context->data[Tree]->tree; |
108 tree->root = 0; | 109 tree->root = 0; |
109 tree->current = 0; | 110 tree->current = 0; |
110 tree->prev = 0; | 111 tree->deleted = 0; |
111 | 112 |
112 context->node_stack = stack_init(sizeof(union Data*), num); | 113 context->node_stack = stack_init(sizeof(union Data*), num); |
113 context->code_stack = stack_init(sizeof(enum Code), 100); | 114 context->code_stack = stack_init(sizeof(enum Code), 100); |
114 } | 115 } |