Skip to content

Commit

Permalink
Add an authorship and remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
byeonggiljun committed Apr 11, 2024
1 parent 5ec3325 commit 3b50275
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 159 deletions.
43 changes: 9 additions & 34 deletions core/utils/pqueue_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
* - The provided pqueue_eq_elem_f implementation is used to test and
* search for equal elements present in the queue; and
* - Removed capability to reassign priorities.
*
* Modified by Byeonggil Jun (Apr, 2024).
* Changes:
* - Made the pqueue_cmp_pri_f function return do the three-way comparison
* rather than the two-way comparison.
* - The changed pqueue_cmp_pri_f function is used to check the equality of
* two elements in the pqueue_find_equal_same_priority function.
* - Remove the pqueue_find_equal function.
*
*/

#include <stdlib.h>
Expand All @@ -44,38 +53,6 @@
#define LF_RIGHT(i) (((i) << 1) + 1)
#define LF_PARENT(i) ((i) >> 1)

void* find_equal(pqueue_t* q, void* e, int pos, pqueue_pri_t max) {
if (pos < 0) {
lf_print_error_and_exit("find_equal() called with a negative pos index.");
}

// Stop the recursion when we've reached the end of the
// queue. This has to be done before accessing the queue
// to avoid segmentation fault.
if (!q || (size_t)pos >= q->size) {
return NULL;
}

void* rval;
void* curr = q->d[pos];

// Stop the recursion when we've surpassed the maximum priority.
if (!curr || q->cmppri(q->getpri(curr), max) == 1) {
return NULL;
}

if (q->eqelem(curr, e)) {
return curr;
} else {
rval = find_equal(q, e, LF_LEFT(pos), max);
if (rval)
return rval;
else
return find_equal(q, e, LF_RIGHT(pos), max);
}
return NULL;
}

static void* find_same_priority(pqueue_t* q, void* e, int pos) {
if (pos < 0) {
lf_print_error_and_exit("find_same_priority() called with a negative pos index.");
Expand Down Expand Up @@ -227,8 +204,6 @@ static void percolate_down(pqueue_t* q, size_t i) {
q->setpos(moving_node, i);
}

void* pqueue_find_equal(pqueue_t* q, void* e, pqueue_pri_t max) { return find_equal(q, e, 1, max); }

void* pqueue_find_same_priority(pqueue_t* q, void* e) { return find_same_priority(q, e, 1); }

void* pqueue_find_equal_same_priority(pqueue_t* q, void* e) { return find_equal_same_priority(q, e, 1); }
Expand Down
115 changes: 0 additions & 115 deletions core/utils/pqueue_support.h

This file was deleted.

18 changes: 8 additions & 10 deletions include/core/utils/pqueue_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
* search for equal elements present in the queue; and
* - Removed capability to reassign priorities.
*
* Modified by Byeonggil Jun (Apr, 2024).
* Changes:
* - Made the pqueue_cmp_pri_f function return do the three-way comparison
* rather than the two-way comparison.
* - The changed pqueue_cmp_pri_f function is used to check the equality of
* two elements in the pqueue_find_equal_same_priority function.
* - Remove the pqueue_find_equal function.
*
* @brief Priority Queue function declarations used as a base for Lingua Franca priority queues.
*
* @{
Expand Down Expand Up @@ -139,16 +147,6 @@ void* pqueue_pop(pqueue_t* q);
*/
void pqueue_empty_into(pqueue_t** dest, pqueue_t** src);

/**
* Find the highest-ranking item with priority up to and including the given
* maximum priority that matches the supplied entry.
* @param q the queue
* @param e the entry to compare against
* @param max_priority the maximum priority to consider
* @return NULL if no matching event has been found, otherwise the entry
*/
void* pqueue_find_equal(pqueue_t* q, void* e, pqueue_pri_t max_priority);

/**
* Return an entry with the same priority as the specified entry or NULL if there is no such entry.
* @param q the queue
Expand Down

0 comments on commit 3b50275

Please sign in to comment.