annotate final_pre/src/rbtreeContext.h @ 7:0e8b9646d43f

add final_pre
author e155702
date Sun, 17 Feb 2019 05:39:59 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
1 // DataSegments for Red-Black Tree
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
2 union Data {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
3 struct Comparable { // interface
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
4 enum Code compare;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
5 union Data* data;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
6 } compare;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
7 struct Count {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
8 enum Code next;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
9 long i;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
10 } count;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
11 struct Tree {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
12 enum Code next;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
13 struct Node* root;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
14 struct Node* current;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
15 struct Node* deleted;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
16 int result;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
17 } tree;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
18 struct Node {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
19 // need to tree
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
20 enum Code next;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
21 int key; // comparable data segment
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
22 int value;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
23 struct Node* left;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
24 struct Node* right;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
25 // need to balancing
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
26 enum Color {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
27 Red,
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
28 Black,
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
29 } color;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
30 } node;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
31 struct Allocate {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
32 enum Code next;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
33 long size;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
34 } allocate;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
35 };
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
36
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
37
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
38 // Meta DataSegment
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
39 struct Context {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
40 enum Code next;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
41 int codeNum;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
42 __code (**code) (struct Context*);
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
43 void* heapStart;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
44 void* heap;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
45 long heapLimit;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
46 int dataNum;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
47 stack_ptr code_stack;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
48 stack_ptr node_stack;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
49 union Data **data;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
50 };