void dag_node_footprint_prepare_node_terminal_files(struct dag_node *n) { struct dag_file *f; list_first_item(n->target_files); while((f = list_next_item(n->target_files))){ if(f->type == DAG_FILE_TYPE_OUTPUT){ set_push(n->footprint->terminal_files, f); } set_push(n->footprint->coexist_files, f); } struct dag_node *node1; set_first_element(n->ancestors); while((node1 = set_next_element(n->ancestors))){ set_insert_set(n->footprint->terminal_files, node1->footprint->terminal_files); set_first_element(node1->footprint->coexist_files); while((f = set_next_element(node1->footprint->coexist_files))){ if(dag_file_coexist_files(n->footprint->accounted, f)) set_push(n->footprint->coexist_files, f); } } set_first_element(n->descendants); while((node1 = set_next_element(n->descendants))){ node1->footprint->terminal_updated--; if(node1->footprint->terminal_updated <= 0) dag_node_footprint_prepare_node_terminal_files(node1); } }
Wtree* wtree_generate(char* string, int len) { Set* alphabet = set_construct(); int i = 0; for (i = 0; i < len; i++) { set_push(alphabet, string[i]); } char* alphabet_str = set_tostring(alphabet); int alphabet_len = strlen(alphabet_str); Wtree* wtree = wtree_construct(alphabet_str, alphabet_len); for (i = 0; i < len; i++) { wtree_push(wtree, string[i]); } return wtree; }
static AstarArray* search(AstarNode *current, int dst, Set *open_set, Set *close_set, void *ud) { AstarArray *adjs = NULL; if (!current) return NULL; adjs = get_adjs(ud, current->index); int j; for (j = 0; j < adjs->len; j++) { int i = adjs->arr[j]; if (i == dst) { return path_backtrace(current, dst); } if (set_find(close_set, i) != -1) continue; int new_g = gscore(ud, current->index, i) + current->g; int index; if ((index = set_find(open_set, i)) != -1) { AstarNode *node = set_index(open_set, index); if (node->g < new_g) { continue; } node->g = new_g; node->parent = current; set_bubble(open_set, index); } else { AstarNode *node = create_node(ud, i, dst, current); set_insert(open_set, node); } } array_release(&adjs); int x = current->index % 30; int y = current->index / 30; printf("current is %d %d\n",x,y ); fflush(stdout); set_push(close_set, current); AstarNode *next = set_pop(open_set); return search(next, dst, open_set, close_set, ud); }
static inline void *sort(void *a) { set_push(s, a); return a; }