reactor-c
C Runtime for Lingua Franca
|
#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | deque_t |
Typedefs | |
typedef struct deque_t | deque_t |
Functions | |
void | deque_initialize (deque_t *d) |
bool | deque_is_empty (deque_t *d) |
size_t | deque_size (deque_t *d) |
void | deque_push_front (deque_t *d, void *value) |
void | deque_push_back (deque_t *d, void *value) |
void * | deque_pop_front (deque_t *d) |
void * | deque_pop_back (deque_t *d) |
void * | deque_peek_back (deque_t *d) |
void * | deque_peek_front (deque_t *d) |
Copyright (c) 2021, The University of California at Berkeley.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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" =}
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));
Alternatively, you can call initialize:
deque my_deque; deque_initialize(&my_deque);
Initialize the specified deque to an empty deque.
d | The deque. |
Peek at the value on the front of the queue, leaving it on the queue.
d | The queue. |
Peek at the value on the back of the queue, leaving it on the queue.
d | The queue. |
Pop a value from the back of the queue, removing it from the queue.
d | The queue. |
Pop a value from the front of the queue, removing it from the queue.
d | The queue. |
Push a value to the back of the queue.
d | The queue. |
value | The value to push. |
Push a value to the front of the queue.
d | The queue. |
value | The value to push. |