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