-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.h
More file actions
49 lines (39 loc) · 1.1 KB
/
list.h
File metadata and controls
49 lines (39 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
41
42
43
44
45
46
47
48
49
#ifndef LIST_H
#define LIST_H
#include <stddef.h>
#include <stdbool.h>
typedef struct List List;
List *create_list(size_t initial_capacity, bool growable);
typedef List *(*ListEmptyFunc)(size_t, bool);
typedef List *(*ListFilledFunc)(size_t, void *, bool);
typedef List *(*ListFromFunc)(void **, size_t, bool);
typedef List *(*ListGenerateFunc)(size_t, void *(*)(size_t), bool);
typedef List *(*ListUnmodifiableFunc)(void **, size_t);
typedef void (*ListAddFunc)(List *, void *);
typedef void *(*ListGetFunc)(List *, size_t);
typedef void (*ListDestroyFunc)(List *);
typedef void (*ListRemoveFunc)(List *, size_t);
typedef void (*ListExpandFunc)(List *);
struct List
{
size_t capacity;
size_t size;
void **data;
bool is_growable;
bool is_unmodifiable;
ListAddFunc add;
ListGetFunc get;
ListDestroyFunc destroy;
ListRemoveFunc remove;
ListExpandFunc expand;
};
typedef struct
{
ListEmptyFunc empty;
ListFilledFunc filled;
ListFromFunc from;
ListGenerateFunc generate;
ListUnmodifiableFunc unmodifiable;
} ListClass;
extern const ListClass ListFactory;
#endif