Data Structures Lerax  v3.0-102-gaf18
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
list.h
Go to the documentation of this file.
1
12
13#ifndef LIST_H
14#define LIST_H
15
17
24struct ListNode {
25 int key; // optional field, introduced because hash tables
26 int data;
27 struct ListNode *next;
28};
29
36typedef struct ListNode List;
37
38#define EMPTY_LIST (List*) 0
39
40 /******************/
41 /* PUBLIC METHODS */
42 /******************/
43
49
58
68
77
87
96
105
114
123
130
131
138
145
146
153
154
163
172
178
185
186
191int list_equal(List* l_x, List* l_y);
192
193
194 /**********************/
195 /* ADDITIONAL METHODS */
196 /**********************/
197
198
204
210
215int list_less_than(List *l, int n);
216
222
228
234
235
236 /****************/
237 /* UTIL METHODS */
238 /****************/
239
240
246List* list_init(int size_list, ...);
247
253
259
265
271
277
284
285 /*******************/
286 /* PRIVATE METHODS */
287 /*******************/
288
294
300
301
309
317
318
326
327#endif
List * list_search(List *l, int data)
Search on the list by data and return the node which contains it.
void list_free(List *l)
Free memory of List and its nodes.
List * list__new_node(int data)
Create a new node for the list.
int list_equal(List *l_x, List *l_y)
Check if two lists are equal.
void list_reverse(List **l)
Reverse a list (no creating a new) WARNING: side-effects.
List * list_append(List *l, int data)
Insert a new element on the end of the list.
void list_print_reverse(List *l)
Print the list reversed without a new line.
int list_less_than(List *l, int n)
Return the number of numbers less n.
List * list_concat(List *l_x, List *l_y)
Return a concatenation of the two lists as a new list.
List * list_append_node(List *l, struct ListNode *node)
Insert a new node on the end of the list.
List * list_tail(List *l)
Get the tail of the list.
List * list_copy(List *l)
Create a copy of the list l.
int list_head(List *l)
Get the data from the first element.
int list_sum(List *l)
Return the sum of numbers on the list.
List * list_insert(List *l, int data)
Insert a new element on the beginning of the list.
int list__is_perfect_number(int n)
Check if a given number is perfect.
int list_empty(List *l)
Verify if the list is empty.
List * list_insert_with_key(List *l, int key, int data)
Insert a new element on the beginning of the list.
List * list_remove_by_key(List *l, int key)
Remove specific element from List by a key.
List * list_create(void)
create a new list instance
int list_last(List *l)
Get the data from last element.
List * list_remove(List *l, int data)
Remove specific element from List.
List * list_init(int size_list,...)
Create a list based on its variadic arguments.
void list_println(List *l)
Print the list with a new line.
int list_length(List *l)
Return the length of the list.
List * list_append_with_key(List *l, int key, int data)
Insert a new element on the end of the list with key.
int list_pop_head(List **l)
Get and pop the head of the list.
void list_print(List *l)
Print the list without a new line.
List * list_insert_ord(List *l, int data)
Ordered insert of a new element in the list.
List * list_search_by_key(List *l, int key)
Search on the list by key and return the node which contains it.
void list_println_reverse(List *l)
Print the list reversed with a new line.
int list_perfect(List *l)
Return the count of perfect numbers on list.
int list_pop_last(List **l)
Get and pop the last element of the list.
Iterator * list_iterator_data(List *l)
Creates an iterator for the list data.
struct ListNode List
A singly linked list.
Definition list.h:36
Iterator * list_iterator_keys(List *l)
Creates an iterator for the list keys.
List * list_from_iterator(Iterator *it)
Creates a list from an iterator.
A generic iterator struct.
Definition iterator.h:13
A node in a singly linked list.
Definition list.h:24
int data
Definition list.h:26
struct ListNode * next
Definition list.h:27
int key
Definition list.h:25