Data Structures UFC  1.0.0
Essential Data Structures for C language
list.h
Go to the documentation of this file.
1 
13 #ifndef LIST_H
14 #define LIST_H
15 
20 struct ListNode {
21  int data;
22  struct ListNode *next;
23 };
24 
26 typedef struct ListNode List;
27 
28 #define EMPTY_LIST (List*) 0
29 
30  /******************/
31  /* PUBLIC METHODS */
32  /******************/
33 
37 List* list_create(void);
38 
45 List* list_insert(List *l, int data);
46 
53 List* list_append(List *l, int data);
54 
61 List* list_insert_ord(List *l, int data);
62 
69 List* list_search(List *l, int data);
70 
75 void list_print(List *l);
76 
77 
82 void list_println(List *l);
83 
88 void list_print_reverse(List *l);
89 
90 
95 void list_println_reverse(List *l);
96 
97 
104 List* list_remove(List *l, int data);
105 
109 void list_free(List *l);
110 
115 int list_empty(List *l);
116 
117 
121 int list_equal(List* l_x, List* l_y);
122 
123 
124  /**********************/
125  /* ADDITIONAL METHODS */
126  /**********************/
127 
128 
132 int list_perfect(List *l);
133 
137 int list_length(List *l);
138 
142 int list_less_than(List *l, int n);
143 
147 int list_sum(List *l);
148 
152 List* list_copy(List *l);
153 
157 List* list_concat(List *l_x, List* l_y);
158 
159 
160  /****************/
161  /* UTIL METHODS */
162  /****************/
163 
164 
169 List* list_init(int size_list, ...);
170 
174 int list_last(List *l);
175 
179 int list_head(List *l);
180 
184 List* list_tail(List *l);
185 
189 int list_pop_head(List** l);
190 
194 int list_pop_last(List** l);
195 
200 void list_reverse(List** l);
201 
202  /*******************/
203  /* PRIVATE METHODS */
204  /*******************/
205 
209 int list__is_perfect_number(int n);
210 
214 List* list__new_node(int data);
215 
216 #endif
List * list_insert_ord(List *l, int data)
Ordered insert of a new element in the list.
void list_println_reverse(List *l)
Print the list reversed with a new line.
int list_last(List *l)
Get the data from last element.
List * list_init(int size_list,...)
Create a list based on its variadic arguments.
int list_sum(List *l)
Return the sum of numbers on the list.
List * list_concat(List *l_x, List *l_y)
Return a concatenation of the two lists as a new list.
List * list_insert(List *l, int data)
Insert a new element on the beginning of the list.
List * list_tail(List *l)
Get the tail of the list.
List * list_append(List *l, int data)
Insert a new element on the end of the list.
List * list_create(void)
create a new list instance
void list_println(List *l)
Print the list with a new line.
int list_head(List *l)
Get the data from the first element.
void list_print(List *l)
Print the list without a new line.
int data
Definition: list.h:21
List * list_remove(List *l, int data)
Remove specific element from List.
List * list_copy(List *l)
Create a copy of the list l.
int list_less_than(List *l, int n)
Return the number of numbers less n.
int list_length(List *l)
Return the length of the list.
void list_print_reverse(List *l)
Print the list reversed without a new line.
List * list_search(List *l, int data)
Search on the list by data and return the node which contains it.
void list_reverse(List **l)
Reverse a list (no creating a new) WARNING: side-effects.
int list_empty(List *l)
Verify if the list is empty.
struct ListNode * next
Definition: list.h:22
int list_perfect(List *l)
Return the count of perfect numbers on list.
int list_pop_head(List **l)
Get and pop the head of the list.
int list__is_perfect_number(int n)
Check if a given number is perfect.
void list_free(List *l)
Free memory of List and its nodes.
int list_equal(List *l_x, List *l_y)
Check if two lists are equal.
Definition: list.h:20
List * list__new_node(int data)
Create a new node for the list.
int list_pop_last(List **l)
Get and pop the last element of the list.