reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
deque.h File Reference

Implementation of a double-ended queue. More...

#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  deque_t
 A double-ended queue data structure. More...

Typedefs

typedef struct deque_t deque_t
 A double-ended queue data structure.

Functions

void deque_initialize (deque_t *d)
 Initialize the specified deque to an empty deque.
bool deque_is_empty (deque_t *d)
 Return true if the queue is empty.
void * deque_peek_back (deque_t *d)
 Peek at the value on the front of the queue, leaving it on the queue.
void * deque_peek_front (deque_t *d)
 Peek at the value on the back of the queue, leaving it on the queue.
void * deque_pop_back (deque_t *d)
 Pop a value from the back of the queue, removing it from the queue.
void * deque_pop_front (deque_t *d)
 Pop a value from the front of the queue, removing it from the queue.
void deque_push_back (deque_t *d, void *value)
 Push a value to the back of the queue.
void deque_push_front (deque_t *d, void *value)
 Push a value to the front of the queue.
size_t deque_size (deque_t *d)
 Return the size of the queue.

Detailed Description

Implementation of a double-ended queue.

Author
Arthur Deng
Edward A. Lee

This is the header file for an implementation of a double-ended queue. Each node in the queue contains a void* pointer.

To use this, include the following in your target properties:

target C {
cmake-include: "/lib/c/reactor-c/util/deque.cmake"
files: ["/lib/c/reactor-c/util/deque.c", "/lib/c/reactor-c/util/deque.h"]
};

In addition, you need this in your Lingua Franca file:

preamble {=
#include "deque.h"
=}
Implementation of a double-ended queue.

To create a deque, use calloc to ensure that it gets initialized with null pointers and zero size:

deque_t* my_deque = (deque_t*) calloc(1, sizeof(deque_t));
A double-ended queue data structure.
Definition deque.h:52

Alternatively, you can call initialize:

deque my_deque;
deque_initialize(&my_deque);
void deque_initialize(deque_t *d)
Initialize the specified deque to an empty deque.