Corewar documentation 1.0.0
Loading...
Searching...
No Matches
mylist.h
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2023
3** Libmylist
4** File description:
5** The header file of the libmylist
6*/
13#include "my.h"
14
15#ifndef MYLIST_H
16 #define MYLIST_H
17
18// TYPEDEFS :
19
20/* Enum for the type of the data */
21typedef enum type {
22 SHORT_SHORT,
23 SHORT,
24 INT,
25 LONG,
26 LONG_LONG,
27 UNSIGNED_SHORT,
28 UNSIGNED_SHORT_SHORT,
29 UNSIGNED_INT,
30 UNSIGNED_LONG,
31 UNSIGNED_LONG_LONG,
32 SIZE_T,
33 FLOAT,
34 DOUBLE,
35 CHAR,
36 STRING,
37 ARRAY_OF_STRING,
38 VOID,
39 UNKNOWN
40} type_t;
41
42/* Node of the linked list */
43typedef struct node_s {
44 struct node_s *prev; /* Pointer to the previous node */
45 void *data; /* Pointer to the data */
46 type_t type; /* Type of the data */
47 struct node_s *next; /* Pointer to the next node */
48} node_t;
49
50
51
52// FUNCTIONS PROTOTYPES :
53
54 // Add functions :
55
64void my_push_front(node_t **begin, void *data, type_t type);
65
74void my_push_back(node_t **begin, void *data, type_t type);
75
76 // Remove functions :
77
86int my_delete_nodes(node_t **begin, void const *data_ref, int (*cmp)());
87
94void my_delete_list(node_t **begin);
95
102node_t *my_pop_front(node_t **begin);
103
110node_t *my_pop_back(node_t **begin);
111
120node_t *my_pop_node(node_t **begin, void const *data_ref, int (*cmp)());
121
122 // Circular list functions :
123
131void my_push_back_circled(node_t **begin, void *data, type_t type);
132
140int my_list_size_circled(node_t const *begin);
141
147void **my_list_to_array_circled(node_t **list);
148
154void my_delete_circle_list(node_t **begin);
155
156 // Other functions :
157
164void my_show_list(node_t *list);
165
172int my_list_size(node_t const *begin);
173
180void my_rev_list(node_t **begin);
181
190node_t *my_find_node(node_t const *begin, void const *data, int (*cmp)());
191
199void my_concat_list(node_t **begin1, node_t *begin2);
200
208void my_sort_list(node_t **begin, int (*cmp)());
209
218void my_merge_list(node_t **begin1, node_t *begin2, int (*cmp)());
219
226void **my_list_to_array(node_t *list);
227
235node_t *my_params_to_list(int ac, char *const *av);
236
245node_t *my_previous_to_next(node_t **head, node_t *to_delete);
246
247#endif
void my_delete_circle_list(node_t **begin)
Deletes a circular linked list.
Definition my_delete_circled_list.c:20
int my_list_size_circled(node_t const *begin)
Adds a node at the end of the circular linked list.
Definition my_list_size_circled.c:15
void my_push_front(node_t **begin, void *data, type_t type)
Adds a node at the beginning of the list.
Definition my_push_front.c:15
void my_push_back_circled(node_t **begin, void *data, type_t type)
Adds a node at the beginning of the circular linked list.
Definition my_push_back_circled.c:15
int my_list_size(node_t const *begin)
Returns the size of the linked list.
Definition my_list_size.c:15
void my_push_back(node_t **begin, void *data, type_t type)
Adds a node at the end of the list.
Definition my_push_back.c:15
node_t * my_pop_front(node_t **begin)
Removes the first node of the list.
Definition my_pop_front.c:15
node_t * my_previous_to_next(node_t **head, node_t *to_delete)
Skip a node in a linked list and change the previous node to the next node.
Definition my_previous_to_next.c:15
node_t * my_params_to_list(int ac, char *const *av)
Creates a linked list from the arguments (argc and argv)
Definition my_params_to_list.c:15
node_t * my_find_node(node_t const *begin, void const *data, int(*cmp)())
Finds a node in the linked list.
Definition my_find_node.c:15
node_t * my_pop_back(node_t **begin)
Removes the last node of the list.
Definition my_pop_back.c:15
void my_concat_list(node_t **begin1, node_t *begin2)
Concatenates two linked lists.
Definition my_concat_list.c:15
node_t * my_pop_node(node_t **begin, void const *data_ref, int(*cmp)())
Removes a node from the list.
Definition my_pop_node.c:25
void ** my_list_to_array(node_t *list)
Converts the linked list to an array.
Definition my_list_to_array.c:15
void ** my_list_to_array_circled(node_t **list)
Converts the circular linked list to an array.
Definition my_list_to_array_circled.c:15
int my_delete_nodes(node_t **begin, void const *data_ref, int(*cmp)())
Deletes nodes from a linked list.
Definition my_delete_nodes.c:28
void my_show_list(node_t *list)
Displays the linked list.
Definition my_show_list.c:77
void my_sort_list(node_t **begin, int(*cmp)())
Sorts the linked list.
Definition my_sort_list.c:26
void my_delete_list(node_t **begin)
Deletes the linked list.
Definition my_delete_list.c:15
void my_merge_list(node_t **begin1, node_t *begin2, int(*cmp)())
Merges two linked lists.
Definition my_merge_list.c:15
void my_rev_list(node_t **begin)
Reverses the linked list.
Definition my_rev_list.c:15
The header file of the libmy.
Definition mylist.h:43