-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
65 lines (54 loc) · 1.04 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* This file is slist.h
* Single linked list
*
*/
#pragma once
#include <stdlib.h>
#include <stdio.h>
// Forward declaration
typedef struct slist_entry *pslist_entry;
typedef struct slist *pslist;
struct slist_entry
{
pslist_entry next;
int value;
};
struct slist
{
int list_size;
pslist_entry head;
};
/*
* Creates an empty list
* Params: none
* Returns pointer to the list
*/
pslist slist_new(void);
/*
* Deletes list and all the elements
* Params: list - pointer to the list
* Returns none
*/
void slist_delete(pslist list);
/*
* Allocate the element
* put at the end
* Params: list - pointer to the list
* value - value to put in the node
* Returns 0
*/
int slist_insert(pslist list, int value);
/*
Go through the list, remove if value is equal
* Params: list - pointer to the list
* value - value for check
* Returns: 0
*/
int slist_remove(pslist list, int value);
/*
* For each element print in value
* Params: list - pointer to the list
* Returns none
*/
void slist_print(pslist list);