-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
51 lines (34 loc) · 1.64 KB
/
list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Code adapted from @Leyxargon
// Original source: https://github.com/Leyxargon/c-linked-list
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int n; /* data field(s) */
/* float b;
* char c;
* ... etc.
*/
struct node *next; /* pointer to next element */
}Node;
typedef struct list { /* Implemented by José Julio Suárez */
Node *head;
Node *tail;
int length;
}List;
List *newList(); /* Implemented by José Julio Suárez */
Node *newNode(int ); /* physically creates a new node */
/* N.B. this function is called by other functions because does not take care
* of inserting the Node in the list, but delegates this operation to other
* functions, such as *Insert functions */
void headInsert(List *, int ); /* Implemented by José Julio Suárez */
void tailInsert(List *, int ); /* Implemented by José Julio Suárez */
Node *findNode(Node *, int ); /* find a node in the list */
Node *deleteNode(Node *, int ); /* deletes a node corresponding to the inserted key */
int pop(List *, int ); /* Implemented by José Julio Suárez */
Node *extractNode(List * , int ); /* Implemented by José Julio Suárez */
void appendNode(List * , Node * ); /* Implemented by José Julio Suárez */
void appendList(List * , List * ); /* Implemented by José Julio Suárez */
void deleteList(List *); /* Modified by José Julio Suárez */
void printList(List *); /* Implemented by José Julio Suárez */
void printNodes(Node *); /* prints all the nodes in the list */
void Split(List *, List **); /* split the nodes of the list into two sublists */ /* Modified by José Julio Suárez */