summaryrefslogtreecommitdiffstats
path: root/linked_list.h
blob: aefdf29b16566630a9828e0a7e57d1735d2c0ede (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

struct list_item {
    int value;
    struct list_item *next;
};

/* Put x at the end of the list. */
void append(struct list_item *first, int x);

/* Put x at the beginning of the list. */
void prepend(struct list_item *first, int x);

/* Print att elements in the list. */
void print(struct list_item *first);

/* Find the first element in the list larger than x and input x right before
 * that element. */
void input_sorted(struct list_item *first, int x);

/* Free everything dynamically located. */
void clear(struct list_item *first);