lib<g2l> 0.1.0
A simple and experimental C implementation of a generic doubly linked list
Loading...
Searching...
No Matches
g2l.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2024 BB-301 <fw3dg3@gmail.com> [Official repository](https://github.com/BB-301/c-generic-doubly-linked-list)
3
4 Permission is hereby granted, free of charge, to any person
5 obtaining a copy of this software and associated documentation
6 files (the “Software”), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge,
8 publish, distribute, sublicense, and/or sell copies of the Software,
9 and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
28#ifndef _G2L_H_
29#define _G2L_H_
30
31#include <stdbool.h>
32#include <sys/types.h>
33
42typedef struct g2l_t g2l_t;
43
64g2l_t *g2l_create(size_t data_size, bool abort_on_enomem);
65
71void g2l_clear(g2l_t *self);
72
79void g2l_destroy(g2l_t *self);
80
88size_t g2l_size(g2l_t const *self);
89
108int g2l_push(g2l_t *self, void const *data);
109
122bool g2l_pop(g2l_t *self, void *data);
123
138bool g2l_shift(g2l_t *self, void *data);
139
155bool g2l_enqueue(g2l_t *self, void const *data);
156
172bool g2l_dequeue(g2l_t *self, void *data);
173
174#endif
struct g2l_t g2l_t
An opaque data type used as a container for the generic doubly linked list implementation,...
Definition: g2l.h:42
bool g2l_pop(g2l_t *self, void *data)
The function that must be used to "pop" the stack (and optionally retrieve the value contained in the...
size_t g2l_size(g2l_t const *self)
A function that can be used to retrieve the current number of items contained in the linked list obje...
int g2l_push(g2l_t *self, void const *data)
The function that must be used to add a new element to the linked list object self .
bool g2l_dequeue(g2l_t *self, void *data)
An alias to g2l_shift , this function can be used to "dequeue" (i.e., shift) the list's oldest elemen...
void g2l_clear(g2l_t *self)
A function that can be used to clear (i.e., empty) a linked list object.
void g2l_destroy(g2l_t *self)
The function that should be used to destroy a linked list object once it is no longer needed by the a...
g2l_t * g2l_create(size_t data_size, bool abort_on_enomem)
The function that must be used to instantiate a new linked list object (i.e., g2l_t ).
bool g2l_shift(g2l_t *self, void *data)
The function that must be used to "shift" the list's oldest element (and optionally retrieve the valu...
bool g2l_enqueue(g2l_t *self, void const *data)
An alias to g2l_push , a function that can be used to "enqueue" a new element to the linked list obje...