Flowgrind
Advanced TCP traffic generator
fg_list.h
Go to the documentation of this file.
1 
6 /*
7 * Copyright (C) 2014 Marcel Nehring <marcel.nehring@rwth-aachen.de>
8 *
9 * This file is part of Flowgrind.
10 *
11 * Flowgrind is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * Flowgrind is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with Flowgrind. If not, see <http://www.gnu.org/licenses/>.
23 *
24 */
25 
26 #ifndef _FG_LIST_H_
27 #define _FG_LIST_H_
28 
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif /* HAVE_CONFIG_H */
32 
33 #include <stddef.h>
34 
36 struct list_node {
38  void* data;
40  struct list_node* next;
43 };
44 
46 struct linked_list {
48  struct list_node* head;
50  struct list_node* tail;
52  size_t size;
53 };
54 
61 int fg_list_init(struct linked_list * const list);
62 
71 const struct list_node* fg_list_front(struct linked_list * const list);
72 
81 const struct list_node* fg_list_back(struct linked_list * const list);
82 
93 int fg_list_remove(struct linked_list * const list, const void * const data);
94 
105 int fg_list_push_front(struct linked_list * const list, void * const data);
106 
117 void* fg_list_pop_front(struct linked_list * const list);
118 
129 int fg_list_push_back(struct linked_list * const list, void * const data);
130 
141 void* fg_list_pop_back(struct linked_list * const list);
142 
149 size_t fg_list_size(struct linked_list * const list);
150 
157 int fg_list_clear(struct linked_list * const list);
158 
159 #endif /* _FG_LIST_H_ */
fg_list_remove
int fg_list_remove(struct linked_list *const list, const void *const data)
Removes from the list the first element whose data points to data.
Definition: fg_list.c:65
fg_list_size
size_t fg_list_size(struct linked_list *const list)
Returns the number of elements in the list.
Definition: fg_list.c:211
fg_list_init
int fg_list_init(struct linked_list *const list)
Initializes the list by setting its head and tail to NULL and its size to 0.
Definition: fg_list.c:34
fg_list_back
const struct list_node * fg_list_back(struct linked_list *const list)
Returns the last element of the list.
Definition: fg_list.c:57
list_node::data
void * data
Pointer to user defined data stored with this node.
Definition: fg_list.h:38
fg_list_clear
int fg_list_clear(struct linked_list *const list)
Removes and destroys all elements from the list, leaving it with a size of 0.
Definition: fg_list.c:219
list_node::previous
struct list_node * previous
Pointer to the next node in the list.
Definition: fg_list.h:42
linked_list::head
struct list_node * head
Pointer to the first element in the list.
Definition: fg_list.h:48
linked_list::size
size_t size
Size of the list i.e.
Definition: fg_list.h:52
fg_list_pop_front
void * fg_list_pop_front(struct linked_list *const list)
Removes the first element in the list, effectively reducing its size by one.
Definition: fg_list.c:144
linked_list::tail
struct list_node * tail
Pointer to the last element in the list.
Definition: fg_list.h:50
fg_list_push_back
int fg_list_push_back(struct linked_list *const list, void *const data)
Inserts a new element at the end of the list.
Definition: fg_list.c:167
list_node
Single element in a doubly linked list.
Definition: fg_list.h:36
linked_list
A doubly linked list.
Definition: fg_list.h:46
config.h
list_node::next
struct list_node * next
Pointer to the previous node in the list.
Definition: fg_list.h:40
fg_list_pop_back
void * fg_list_pop_back(struct linked_list *const list)
Removes the last element in the list, effectively reducing its size by one.
Definition: fg_list.c:188
fg_list_push_front
int fg_list_push_front(struct linked_list *const list, void *const data)
Inserts a new element at the beginning of the list.
Definition: fg_list.c:123
fg_list_front
const struct list_node * fg_list_front(struct linked_list *const list)
Returns the first element of the list.
Definition: fg_list.c:49