-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.h
More file actions
40 lines (31 loc) · 1.1 KB
/
Copy pathlist.h
File metadata and controls
40 lines (31 loc) · 1.1 KB
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
// Copyright (C) 2024 Aleksei Rogov <alekzzzr@gmail.com>. All rights reserved.
#ifndef _LIST_H
#define _LIST_H
#define LIST_PARAM_ERROR -1
#define LIST_ALLOC_ERROR -2
#define LIST_IS_EMPTY -3
#define LIST_OUT_OF_RANGE -4
#define LIST_UNCHANGED -5
#define LIST_SUCCESS 1
struct LIST {
int field;
struct LIST *next;
struct LIST *prev;
};
// Create a new linked list if '*list' is NULL, and append an 'object' to it
// Otherwise, add a new 'object' to the end of the 'list'
// Return MT_LIST_SUCCESS if no errors
int list_add(struct LIST **list, const struct LIST *object);
// Insert 'object' into 'list' at position 'position'
// Return MT_LIST_SUCCESS if no errors
int list_insert(struct LIST **list, const struct LIST *object, int position);
// Copy node number 'n' to 'object'
// Return MT_LIST_SUCCESS if no errors
int list_get_node(struct LIST **list, struct LIST *object, int n);
// Remove object number 'n' from the 'list'
// Return MT_LIST_SUCCESS if no errors
int list_del(struct LIST **list, int n);
// Destroy 'list'
// Return MT_LIST_SUCCESS if no errors
int list_destroy(struct LIST **list);
#endif