-
Notifications
You must be signed in to change notification settings - Fork 6
/
linked_list.h
40 lines (29 loc) · 918 Bytes
/
linked_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
// --------------------------------------------------------------------------
//
// C Kong
// Copyright (C) 2018 Jeff Panici
// All rights reserved.
//
// This software source file is licensed according to the
// MIT License. Refer to the LICENSE file distributed along
// with this source file to learn more.
//
// --------------------------------------------------------------------------
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct ll_node ll_node_t;
typedef struct ll_node {
uint32_t key;
void* data;
ll_node_t* prev;
ll_node_t* next;
} ll_node_t;
ll_node_t* ll_new_node();
void ll_free(ll_node_t* node);
uint32_t ll_size(ll_node_t* node);
bool ll_is_head(const ll_node_t* node);
bool ll_is_tail(const ll_node_t* node);
void ll_insert_after(ll_node_t* node, ll_node_t* new_node);
void ll_insert_before(ll_node_t* node, ll_node_t* new_node);