diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-22 12:23:35 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-22 12:23:35 +0300 |
| commit | d96ba29434808b94cccfcce7a675e5abbd2d846d (patch) | |
| tree | f02ce36a0ec0acbc87d0a454062e6300445ad0f2 /priority_queue.c | |
| parent | 348c700fedae3b0005660d8c42941fe7c69027d4 (diff) | |
Add ability to choose maps via args + create more maps + don't insert elements into a PPQ if there's one with better priority
Diffstat (limited to 'priority_queue.c')
| -rw-r--r-- | priority_queue.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/priority_queue.c b/priority_queue.c index c8bd8b0..472f5c3 100644 --- a/priority_queue.c +++ b/priority_queue.c @@ -12,6 +12,7 @@ PositionPQ *ppq_new(Position pos, size_t priority) { return ppq; } +/* FIXME: this is shitty */ void ppq_insert(PositionPQ **ppq, Position pos, size_t priority) { PositionPQ *start = *ppq; @@ -29,8 +30,12 @@ void ppq_insert(PositionPQ **ppq, Position pos, size_t priority) { PositionPQ *temp = *ppq; - while(temp->next != NULL && temp->next->priority <= priority) + while(temp->next != NULL && temp->next->priority <= priority) { + if (temp->pos.x == pos.x && temp->pos.y == pos.y && temp->priority <= priority) { + return; /* pos is already at the start of ppq with a fine priority */ + } temp = temp->next; + } n->next = temp->next; temp->next = n; |
