annotate src/list/listContext.h @ 35:2bdd8e2118c7

Add tail pointer to List data segment
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 05 May 2015 21:16:04 +0900
parents c3314208d7b9
children 2ff693c5563c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Context definition for list example */
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #define ALLOCATE_SIZE 100
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 enum Code {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 Code1,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 Code2,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Code3,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Code4,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 Code5,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 Code6,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 Allocator,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 Append,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 Traverse,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 Delete,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 Exit,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 };
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 enum UniqueData {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 Allocate,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 List,
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 };
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 struct Context {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 int codeNum;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 __code (**code) (struct Context *);
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 void* heap_start;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 void* heap;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 long dataSize;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 int dataNum;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 union Data* head;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 union Data** data;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 };
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 union Data {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 long count;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 struct List {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 union Data* head;
35
2bdd8e2118c7 Add tail pointer to List data segment
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
39 union Data* tail;
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 union Data* current;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 } list;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 struct Element {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 int value;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 union Data* next;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 } element;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 struct Allocate {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 long size;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 enum Code next;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 enum Code after_append;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 enum Code after_delete;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 enum Code after_traverse;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 } allocate;
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 };