-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynarr.h
More file actions
61 lines (48 loc) · 1.63 KB
/
Copy pathdynarr.h
File metadata and controls
61 lines (48 loc) · 1.63 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
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef DYNARR_H
#define DYNARR_H
/***********************************************************************
* Types
***********************************************************************/
struct dynarr {
void *content;
int elemsize;
int capacity;
int length;
};
/***********************************************************************
* Constructors
***********************************************************************/
/**
* Constructs a dynamic array with the specified element size.
* @param size the element size
* @return the newly created dynamic array
*/
struct dynarr da_new(int size);
/* ******************************************************************* *
* Destructors
* ******************************************************************* */
/**
* Releases memory held by this dynamic array.
* @param dynarr this dynamic array
*/
void da_free(struct dynarr);
/***********************************************************************
* Functions
***********************************************************************/
/**
* Inserts the given value into this dynamic array.
* The contents may be reallocated and moved.
* In this case, all pointers to the contents are invalidated.
* @param arr this dynamic array
* @param data a reference to the object that should be inserted
* @return whether insertion was successful
*/
_Bool da_append(struct dynarr *arr, void const *data);
/**
* Retrieves the value at the given index in this dynamic array.
* @param arr this dynamic array
* @param i the target index
* @return a reference to the specified value
*/
void *da_get(struct dynarr arr, int i);
#endif