reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
pqueue_tag_element_t Struct Reference

The type for an element in a priority queue that is sorted by tag. More...

#include <pqueue_tag.h>

Data Fields

tag_t tag
 
size_t pos
 
int is_dynamic
 

Detailed Description

The type for an element in a priority queue that is sorted by tag.

In this design, a pointer to this struct is also a "priority" (it can be cast to pqueue_pri_t). The actual priority is the tag field of the struct, in that the queue is sorted from least tag to largest.

If your struct is dynamically allocated using malloc or calloc, and you would like the memory freed when the queue is freed, then set the is_dynamic field of the element to a non-zero value.

For a priority queue that contains only tags with no payload, you can avoid creating the element struct by using the functions pqueue_tag_insert_tag, pqueue_tag_insert_if_no_match, and pqueue_tag_pop_tag.

To customize the element you put onto the queue, for example to carry a payload, you can create your own element struct type by simply declaring the first field to be a pqueue_tag_element_t. For example, if you want an element of the queue to include a pointer to your own payload, you can declare the following struct type:

    typedef struct {
        pqueue_tag_element_t base;
        my_type* my_payload;
    } my_element_type_t;

When inserting your struct into the queue, simply cast your pointer to (pqueue_tag_element_t*). When accessing your struct from the queue, simply cast the result to (my_element_type_t*);

Field Documentation

◆ is_dynamic

int pqueue_tag_element_t::is_dynamic

◆ pos

size_t pqueue_tag_element_t::pos

◆ tag

tag_t pqueue_tag_element_t::tag

The documentation for this struct was generated from the following file: