int main() { struct bucket_array* b = ba_init(); struct generic_data d; d.key = "music"; d.key_l = 5; d.value = 2; printf("This new bucket has %d elements.\n", ba_size(b)); ba_insert(b, d, 4); printf("Now, this bucket has %d elements.\n", ba_size(b)); struct generic_data *p_d = ba_get(b, 4, "music", 5); printf("Let's see what's there: %s\n", p_d->key); printf("Let's remove this entry. "); ba_remove(b, 4, "music", 5); printf("The new size of the bucket array is %d.\n", ba_size(b)); d.key = "hiking"; d.key_l = 6; d.value = 5; ba_insert(b, d, 4); printf("Let's add a new element, and the new size is %d.\n", ba_size(b)); p_d = ba_get(b, 4, "hiking", 5); printf("The new element is: %s, %d\n", p_d->key, p_d->value); d.value = 10; ba_set(b, 4, "hiking", 5, d.value); p_d = ba_get(b, 4, "hiking", 5); printf("Set %s to %d\n", p_d->key, p_d->value); ba_insert(b, d, 20); ba_increase(b); }
hash_tbl_t* ht_init_hash(hash_func_t *hash_it) { hash_table *n_ht = malloc(sizeof(*n_ht)); n_ht->func = malloc(sizeof(*n_ht->func)); n_ht->func = *hash_it; n_ht->buckets = ba_init(); }
int main(int argc, char** argv) { select_ba_request_t *request = xmalloc(sizeof(select_ba_request_t)); log_options_t log_opts = LOG_OPTS_INITIALIZER; int debug_level = 5; List results; // List results2; // int i,j; log_opts.stderr_level = debug_level; log_opts.logfile_level = debug_level; log_opts.syslog_level = debug_level; log_alter(log_opts, LOG_DAEMON, "/dev/null"); DIM_SIZE[X]=0; DIM_SIZE[Y]=0; DIM_SIZE[Z]=0; slurm_conf_reinit(NULL); ba_init(NULL, 1); /* [010x831] */ /* results = list_create(NULL); */ /* request->geometry[0] = 9; */ /* request->geometry[1] = 3; */ /* request->geometry[2] = 2; */ /* request->start[0] = 0; */ /* request->start[1] = 1; */ /* request->start[2] = 0; */ /* request->start_req = 1; */ /* // request->size = 16; */ /* request->rotate = 0; */ /* request->elongate = 0; */ /* request->conn_type = SELECT_TORUS; */ /* new_ba_request(request); */ /* print_ba_request(request); */ /* if (!allocate_block(request, results)) { */ /* debug("couldn't allocate %c%c%c", */ /* alpha_num[request->geometry[0]], */ /* alpha_num[request->geometry[1]], */ /* alpha_num[request->geometry[2]]); */ /* } */ /* list_destroy(results); */ /* /\* [001x801] *\/ */ /* results = list_create(NULL); */ /* request->geometry[0] = 9; */ /* request->geometry[1] = 1; */ /* request->geometry[2] = 1; */ /* request->start[0] = 0; */ /* request->start[1] = 0; */ /* request->start[2] = 1; */ /* request->start_req = 1; */ /* // request->size = 1; */ /* request->rotate = 0; */ /* request->elongate = 0; */ /* request->conn_type = SELECT_TORUS; */ /* new_ba_request(request); */ /* print_ba_request(request); */ /* if (!allocate_block(request, results)) { */ /* debug("couldn't allocate %c%c%c", */ /* request->geometry[0], */ /* request->geometry[1], */ /* request->geometry[2]); */ /* } */ /* list_destroy(results); */ /* [001x801] */ results = list_create(NULL); request->geometry[0] = 7; request->geometry[1] = 4; request->geometry[2] = 2; request->start[0] = 0; request->start[1] = 0; request->start[2] = 0; request->start_req = 0; // request->size = 1; request->rotate = 1; request->elongate = 1; request->conn_type[0] = SELECT_TORUS; new_ba_request(request); print_ba_request(request); if (!allocate_block(request, results)) { debug("couldn't allocate %c%c%c", request->geometry[0], request->geometry[1], request->geometry[2]); } list_destroy(results); int dim,j; int x,y,z; int startx=0; int starty=0; int startz=0; int endx=DIM_SIZE[X]; int endy=1;//DIM_SIZE[Y]; int endz=1;//DIM_SIZE[Z]; for(x=startx;x<endx;x++) { for(y=starty;y<endy;y++) { for(z=startz;z<endz;z++) { ba_mp_t *curr_node = &(ba_main_grid[x][y][z]); info("Node %c%c%c Used = %d", alpha_num[x],alpha_num[y],alpha_num[z], curr_node->used); for(dim=0;dim<1;dim++) { info("Dim %d",dim); ba_switch_t *wire = &curr_node->axis_switch[dim]; for(j=0;j<NUM_PORTS_PER_NODE;j++) info("\t%d -> %d -> %c%c%c %d " "Used = %d", j, wire->int_wire[j]. port_tar, alpha_num[wire->ext_wire[ wire->int_wire[j]. port_tar]. mp_tar[X]], alpha_num[wire->ext_wire[ wire->int_wire[j]. port_tar]. mp_tar[Y]], alpha_num[wire->ext_wire[ wire->int_wire[j]. port_tar]. mp_tar[Z]], wire->ext_wire[ wire->int_wire[j]. port_tar]. port_tar, wire->int_wire[j].used); } } } } /* list_destroy(results); */ /* ba_fini(); */ /* delete_ba_request(request); */ return 0; }