-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathctl_numeric.h
More file actions
43 lines (37 loc) · 924 Bytes
/
Copy pathctl_numeric.h
File metadata and controls
43 lines (37 loc) · 924 Bytes
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
// Optional numeric algorithms
// requested via INCLUDE_NUMERIC
// SPDX-License-Identifier: MIT
// For non-POD T types need a T_inc method.
#undef CTL_NUMERIC
#define CTL_NUMERIC
#if !defined(CTL_USET) && !defined(CTL_SET) && !defined(CTL_PQU)
static inline void JOIN(A, iota)(A* self, T value) {
ctl_foreach(A, self, i) {
#ifdef POD
*i.ref = value;
value += 1;
#else
if (self->free)
self->free(i.ref);
// inc already copies the value
*i.ref = JOIN(T, inc)(&value);
//value = self->copy(&value);
#endif
}
}
static inline void JOIN(A, iota_range)(I* range, T value) {
#ifndef POD
A* self = range->container;
#endif
ctl_foreach_range_(A, i, range) {
#ifdef POD
*i.ref = value;
value += 1;
#else
if (self->free)
self->free(i.ref);
*i.ref = JOIN(T, inc)(&value);
#endif
}
}
#endif // PQU,USET,SET