annotate paper/src/rbtreeContext.h @ 71:b0cfef1cd89f

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