diff options
author | Marvin Borner | 2023-05-27 00:37:19 +0200 |
---|---|---|
committer | Marvin Borner | 2023-05-27 00:37:19 +0200 |
commit | ac039e6fcbdec3dc6c8e28013e1b3a20068c84ee (patch) | |
tree | e0b9db6a303e1369054b478cc44a8ea7d3d7d44d /src/map.c | |
parent | 90a0366ba0556314b8624a3f46c667eaf5824e4c (diff) |
Basic schedule initialization
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -12,10 +12,10 @@ static struct hashmap *all_terms; static void deref_term(struct term *term) { if (term->type == ABS) { - deref_term(hashmap_get(all_terms, term->u.abs.term)); + deref_term(term->u.abs.term); } else if (term->type == APP) { - deref_term(hashmap_get(all_terms, term->u.app.lhs)); - deref_term(hashmap_get(all_terms, term->u.app.rhs)); + deref_term(term->u.app.lhs); + deref_term(term->u.app.rhs); } // TODO: remove from hashmap? @@ -51,3 +51,19 @@ void map_destroy(void) { hashmap_free(all_terms); } + +struct pqueue *map_to_pqueue(pqueue_cmp_pri_f cmppri, pqueue_get_pri_f getpri, + pqueue_set_pos_f setpos) +{ + size_t size = hashmap_count(all_terms) + 42; + struct pqueue *queue = pqueue_init(size, cmppri, getpri, setpos); + + size_t iter = 0; + void *iter_val; + while (hashmap_iter(all_terms, &iter, &iter_val)) { + struct term *term = *(struct term **)iter_val; + pqueue_insert(queue, term); + } + + return queue; +} |