Report abuse

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* array structure */
typedef struct vd_array_s vd_array_t;

/* comparator callback type */
typedef int (*vd_array_comparator_callback_t)(void *value_1, void *value_2);

/* enumerator callback type */
typedef void (*vd_array_enumerator_callback_t)(vd_data_t *a_data, ssize_t a_index);

/* predicate callback type */
typedef bool (*vd_array_predicate_callback_t)(vd_data_t *a_data);

/* map callback type */
typedef vd_data_t *(*vd_array_map_callback_t)(vd_data_t *a_data);

#pragma mark -

/* creates an array */
vd_array_t *vd_array_create(ssize_t a_initial_capacity);

/* creates a sorted array */
vd_array_t *vd_array_create_sorted(ssize_t a_initial_capacity, vd_array_comparator_callback_t a_callback);

/* deletes an array */
void vd_array_destroy(vd_array_t *a_array);

#pragma mark -

/* inserts element at end of a non-sorted array */
int vd_array_append(vd_array_t *a_array, vd_data_t *a_data);

/* appends all elements in the second array to the first array */
int vd_array_append_array(vd_array_t *a_array, vd_array_t *a_array_2);

/* appends unique elements in the second array to the first array */
int vd_array_union_array(vd_array_t *a_array, vd_array_t *a_array_2);

/* inserts element at begin of a non-sorted array */
int vd_array_prepend(vd_array_t *a_array, vd_data_t *a_data);

/* inserts element in a sorted array */
int vd_array_insert(vd_array_t *a_array, vd_data_t *a_data);

/* inserts element at specified index of a non-sorted array */
int vd_array_insert_at_index(vd_array_t *a_array, vd_data_t *a_data, ssize_t a_index);

#pragma mark -

/* empties the array */
int vd_array_empty(vd_array_t *a_array);

/* removes elements not found in both arrays from first array */
int vd_array_intersect_array(vd_array_t *a_array, vd_array_t *a_array_2);

/* removes elements in second array from first array */
int vd_array_minus_array(vd_array_t *a_array, vd_array_t *a_array_2);

/* deletes element */
int vd_array_delete(vd_array_t *a_array, vd_data_t *a_data);

/* deletes element at index */
int vd_array_delete_at_index(vd_array_t *a_array, ssize_t a_index);

/* deletes elements in range */
int vd_array_delete_in_range(vd_array_t *a_array, ssize_t a_index_min, ssize_t a_index_max);

/* deletes all doubles in the array */
int vd_array_delete_doubles(vd_array_t *a_array);

/* deletes all uniques in the array */
int vd_array_delete_uniques(vd_array_t *a_array);

/* removes NULL values from array */
int vd_array_compact(vd_array_t *a_array);

/* removes elements matching given predicate */
int vd_array_reject(vd_array_t *a_array, vd_array_predicate_callback_t a_callback);

/* removes elements not matching given predicate */
int vd_array_select(vd_array_t *a_array, vd_array_predicate_callback_t a_callback);

#pragma mark -

/* sets the array comparator */
void vd_array_set_comparator(vd_array_t *a_array, vd_array_comparator_callback_t a_callback);

/* fills the array with the specified data */
int vd_array_fill(vd_array_t *a_array, vd_data_t *a_data);

/* fills the range with the specified data */
int vd_array_fill_in_range(vd_array_t *a_array, ssize_t a_index_min, ssize_t a_index_max, vd_data_t *a_data);

/* reverses the array */
int vd_array_reverse(vd_array_t *a_array);

/* sorts the array */
int vd_array_sort(vd_array_t *a_array);

/* maps every element to a new element */
int vd_array_map(vd_array_t *a_array, vd_array_map_callback_t a_callback);

#pragma mark -

/* checks whether a stack is empty */
bool vd_array_is_empty(vd_array_t *a_array);

/* checks whether a stack is sorted */
bool vd_array_is_sorted(vd_array_t *a_array);

/* gets the number of used element slots */
ssize_t vd_array_get_size(vd_array_t *a_array);

/* gets the number of used and free element slots */
ssize_t vd_array_get_capacity(vd_array_t *a_array);

/* gets the number of free element slots */
ssize_t vd_array_get_free_size(vd_array_t *a_array);

/* gets the element at the specified index */
vd_data_t *vd_array_get_element_at_index(vd_array_t *a_array, ssize_t a_index);

/* gets the elements in the specified range */
vd_array_t *vd_array_get_elements_in_range(vd_array_t *a_array, ssize_t a_index_min, ssize_t a_index_max);

/* gets the first element */
vd_data_t *vd_array_get_first(vd_array_t *a_array);

/* gets the last element */
vd_array_t *vd_array_get_last(vd_array_t *a_array);

/* gets the largest element */
vd_data_t *vd_array_get_max(vd_array_t *a_array);

/* gets the smallest element */
vd_array_t *vd_array_get_min(vd_array_t *a_array);

/* enumerates all elements */
void vd_array_enumerate_each(vd_array_t *a_array, vd_array_enumerator_callback_t a_callback);

/* enumerates all elements in reverse order */
void vd_array_enumerate_each_reversed(vd_array_t *a_array, vd_array_enumerator_callback_t a_callback);

/* checks whether two arrays contain the same elements */
bool vd_array_is_equal(vd_array_t *a_array, vd_array_t *a_array_2);

/* checks whether the array contains the given element */
bool vd_array_contains(vd_array_t *a_array, vd_data_t *a_data);

/* checks whether the first array contains all elements of the second array */
bool vd_array_contains_all(vd_array_t *a_array, vd_array_t *a_array_2);

/* checks whether the first array contains any elements of the second array */
bool vd_array_contains_any(vd_array_t *a_array, vd_array_t *a_array_2);