1 | |
---|
2 | #ifndef _AP_BUUFER_INC |
---|
3 | #define _AP_BUUFER_INC |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | /******************* |
---|
9 | |
---|
10 | AP_STACK dynamischer Stack fuer void * |
---|
11 | AP_LIST allgemeine doppelt verketteten Liste |
---|
12 | |
---|
13 | -- Pufferstrukturen |
---|
14 | |
---|
15 | AP_tree_buffer Struktur die im AP_tree gepuffert wird |
---|
16 | |
---|
17 | -- spezielle stacks ( um casts zu vermeiden ) |
---|
18 | |
---|
19 | AP_tree_stack Stack fuer AP_tree_buffer * |
---|
20 | AP_main_stack Stack fuer AP_tree * |
---|
21 | AP_main_list Liste fuer AP_main_buffer |
---|
22 | |
---|
23 | ********************/ |
---|
24 | |
---|
25 | |
---|
26 | struct AP_STACK_ELEM { |
---|
27 | struct AP_STACK_ELEM * next; |
---|
28 | void * node; |
---|
29 | }; |
---|
30 | |
---|
31 | class AP_STACK { |
---|
32 | struct AP_STACK_ELEM * first; |
---|
33 | struct AP_STACK_ELEM * pointer; |
---|
34 | unsigned long stacksize; |
---|
35 | unsigned long max_stacksize; |
---|
36 | |
---|
37 | public: |
---|
38 | AP_STACK(); |
---|
39 | ~AP_STACK(); |
---|
40 | void push(void * element); |
---|
41 | void * pop(); |
---|
42 | void clear(); |
---|
43 | void get_init() ; |
---|
44 | void * get(); |
---|
45 | void * get_first(); |
---|
46 | unsigned long size(); |
---|
47 | }; |
---|
48 | |
---|
49 | /********************************* |
---|
50 | |
---|
51 | AP_LIST |
---|
52 | |
---|
53 | Listenklasse |
---|
54 | |
---|
55 | ********************************/ |
---|
56 | |
---|
57 | struct AP_list_elem { |
---|
58 | AP_list_elem * next; |
---|
59 | AP_list_elem * prev; |
---|
60 | void * node; |
---|
61 | }; |
---|
62 | |
---|
63 | class AP_LIST { |
---|
64 | unsigned int list_len; |
---|
65 | unsigned int akt; |
---|
66 | AP_list_elem *first,*last,*pointer; |
---|
67 | AP_list_elem *element(void * elem); |
---|
68 | public: |
---|
69 | AP_LIST() ; |
---|
70 | ~AP_LIST(); |
---|
71 | int len(); |
---|
72 | int is_element(void * node ); |
---|
73 | int eof(); |
---|
74 | void insert(void * new_one); |
---|
75 | void append(void * new_one); |
---|
76 | void remove(void * object); |
---|
77 | void push(void *elem); |
---|
78 | void * pop(); |
---|
79 | void clear(); |
---|
80 | }; |
---|
81 | |
---|
82 | |
---|
83 | /************************************ |
---|
84 | |
---|
85 | Spezielle Puffer Strukturen |
---|
86 | fuer AP_NTREE |
---|
87 | |
---|
88 | ************************************/ |
---|
89 | class AP_tree_edge; // defined in ap_tree_nlen.hxx |
---|
90 | struct AP_tree_buffer; |
---|
91 | |
---|
92 | struct AP_tree_edge_data |
---|
93 | { |
---|
94 | AP_FLOAT parsValue[3]; // the last three parsimony values (0=lowest 2=highest) |
---|
95 | int distance; // the distance of the last insertion |
---|
96 | }; |
---|
97 | |
---|
98 | |
---|
99 | struct AP_tree_buffer { |
---|
100 | unsigned long controll; // used for internal buffer check |
---|
101 | unsigned int count; // counts how often the entry is buffered |
---|
102 | AP_STACK_MODE mode; |
---|
103 | class AP_sequence * sequence; |
---|
104 | AP_FLOAT mutation_rate; |
---|
105 | double leftlen,rightlen; |
---|
106 | class AP_tree *father; |
---|
107 | class AP_tree *leftson; |
---|
108 | class AP_tree *rightson; |
---|
109 | GBDATA *gb_node; |
---|
110 | |
---|
111 | int distance; // distance to border (pushed with STRUCTURE!) |
---|
112 | // stuff from edges: |
---|
113 | |
---|
114 | class AP_tree_edge *edge[3]; |
---|
115 | int edgeIndex[3]; |
---|
116 | struct AP_tree_edge_data edgeData[3]; |
---|
117 | |
---|
118 | void print(); |
---|
119 | }; |
---|
120 | |
---|
121 | class AP_tree_stack : public AP_STACK { |
---|
122 | public: |
---|
123 | AP_tree_stack() { |
---|
124 | ; |
---|
125 | } |
---|
126 | void push(struct AP_tree_buffer *value) { |
---|
127 | AP_STACK::push((void *)value); |
---|
128 | } |
---|
129 | AP_tree_buffer * pop() { |
---|
130 | return ( AP_tree_buffer *) AP_STACK::pop(); |
---|
131 | } |
---|
132 | AP_tree_buffer * get() { |
---|
133 | return ( AP_tree_buffer *) AP_STACK::get(); |
---|
134 | } |
---|
135 | AP_tree_buffer * get_first() { |
---|
136 | return ( AP_tree_buffer *) AP_STACK::get_first(); |
---|
137 | } |
---|
138 | void print(); |
---|
139 | }; |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | class AP_main_stack : public AP_STACK { |
---|
144 | protected: |
---|
145 | unsigned long last_user_buffer; |
---|
146 | public: |
---|
147 | friend class AP_main; |
---|
148 | void push(AP_tree *value) { |
---|
149 | AP_STACK::push((void *)value); |
---|
150 | } |
---|
151 | AP_tree * pop() { |
---|
152 | return (AP_tree *) AP_STACK::pop(); |
---|
153 | } |
---|
154 | AP_tree * get() { |
---|
155 | return (AP_tree *) AP_STACK::get(); |
---|
156 | } |
---|
157 | AP_tree * get_first() { |
---|
158 | return (AP_tree *) AP_STACK::get_first(); |
---|
159 | } |
---|
160 | void print(); |
---|
161 | }; |
---|
162 | |
---|
163 | |
---|
164 | class AP_main_list : public AP_LIST { |
---|
165 | public: |
---|
166 | AP_main_stack * pop() { |
---|
167 | return (AP_main_stack *)AP_LIST::pop(); |
---|
168 | } |
---|
169 | void push(AP_main_stack * stack) { |
---|
170 | AP_LIST::push( (void *) stack); |
---|
171 | } |
---|
172 | void insert(AP_main_stack * stack) { |
---|
173 | AP_LIST::insert((void *)stack); |
---|
174 | } |
---|
175 | void append(AP_main_stack * stack) { |
---|
176 | AP_LIST::append((void *)stack); |
---|
177 | } |
---|
178 | }; |
---|
179 | |
---|
180 | #endif |
---|