Mercurial > hg > Gears > GearsAgda
annotate src/llrb/llrbContext.h @ 27:44879c87c2dc
modify
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 01 May 2015 18:18:36 +0900 |
parents | 7494c0b87ec4 |
children | 44914699ee9b |
rev | line source |
---|---|
19 | 1 /* Context definition for llrb example */ |
2 | |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
3 #define ALLOCATE_SIZE 100 |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
4 |
19 | 5 enum Code { |
6 Code1, | |
7 Code2, | |
21 | 8 Code3, |
22
4c3c0ad4a75d
add benchmark method
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
9 Code4, |
4c3c0ad4a75d
add benchmark method
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
10 Code5, |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
11 Allocator, |
19 | 12 Put, |
24
7494c0b87ec4
implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
13 Clone, |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
14 InitNode, |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
15 Compare, |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
16 Insert, |
24
7494c0b87ec4
implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
17 RotateL, |
7494c0b87ec4
implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
18 RotateR, |
7494c0b87ec4
implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
19 ColorFlip, |
27 | 20 FixUp, |
24
7494c0b87ec4
implement insert of Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
23
diff
changeset
|
21 ChangeRef, |
19 | 22 Exit, |
23 }; | |
24 | |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
25 enum UniqueData { |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
26 Allocate, |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
27 Tree, |
19 | 28 }; |
29 | |
30 struct Context { | |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
31 int codeNum; |
19 | 32 __code (**code) (struct Context *); |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
33 void* heap_start; |
19 | 34 void* heap; |
35 union Data* root; | |
20 | 36 union Data* current; |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
37 long dataSize; |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
38 int dataNum; |
19 | 39 union Data **data; |
40 }; | |
41 | |
42 union Data { | |
21 | 43 long count; |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
44 struct Tree { |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
45 union Data* root; |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
46 union Data* current; |
27 | 47 union Data* prev; |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
48 int result; |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
49 } tree; |
19 | 50 struct Node { |
51 int key; | |
52 int value; | |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
53 enum Color { |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
54 Red, |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
55 Black, |
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
56 } color; |
19 | 57 union Data* left; |
58 union Data* right; | |
59 } node; | |
60 struct Allocate { | |
61 long size; | |
62 enum Code next; | |
63 enum Code after_put; | |
23
868c2918b634
Non Destructive llrb
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
64 struct Node node; |
19 | 65 } allocate; |
66 }; |