diff options
| author | Tyge Løvset <[email protected]> | 2022-04-15 22:09:22 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-15 22:09:22 +0200 |
| commit | 19a29acc7d2a54edd7f5a4e7f653cb5d1703a09c (patch) | |
| tree | bee31d8a58b4d9124e0c43956e0c6d4fe490da1d | |
| parent | fa261ddd307de9b7bb2965a066fd83b66d8d83a7 (diff) | |
| parent | 5d1de359348733896b6d4448a465ce3b7d9d0684 (diff) | |
| download | STC-modified-19a29acc7d2a54edd7f5a4e7f653cb5d1703a09c.tar.gz STC-modified-19a29acc7d2a54edd7f5a4e7f653cb5d1703a09c.zip | |
Merge branch 'master' of github.com:tylov/STC
| -rw-r--r-- | examples/list.c | 4 | ||||
| -rw-r--r-- | include/stc/alt/clist.h | 4 | ||||
| -rw-r--r-- | include/stc/clist.h | 4 | ||||
| -rw-r--r-- | include/stc/template.h | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/examples/list.c b/examples/list.c index 2d672cf3..fd923719 100644 --- a/examples/list.c +++ b/examples/list.c @@ -10,7 +10,7 @@ int main() { int k;
const int n = 2000000;
- c_auto (clist_fx, list)
+ c_auto (clist_fx, list)
{
stc64_t rng = stc64_init(1234);
stc64_uniformf_t dist = stc64_uniformf_init(100.0f, n);
@@ -37,6 +37,8 @@ int main() { clist_fx_clear(&list);
c_apply(v, clist_fx_push_back(&list, v), int, {10, 20, 30, 40, 30, 50});
+ const double* v = clist_fx_get(&list, 30);
+ printf("found: %f\n", *v);
c_foreach (i, clist_fx, list) printf(" %g", *i.ref);
puts("");
diff --git a/include/stc/alt/clist.h b/include/stc/alt/clist.h index 2d22a1b1..2fdaf427 100644 --- a/include/stc/alt/clist.h +++ b/include/stc/alt/clist.h @@ -207,7 +207,7 @@ STC_API size_t _clist_count(const clist_VOID* self); _cx_iter i = it1; \
for (_cx_memb(_next)(&i); i.ref != it2.ref; _cx_memb(_next)(&i)) { \
i_valraw r = i_valto(i.ref); \
- if (!(i_cmp((&r), (&val)))) return it1; \
+ if (i_eq((&r), (&val))) return it1; \
it1 = i; \
} \
it1.ref = NULL; return it1; \
@@ -243,7 +243,7 @@ STC_API size_t _clist_count(const clist_VOID* self); while (prev) { \
node = prev->next; \
i_valraw r = i_valto((&node->value)); \
- if (!(i_cmp((&r), (&val)))) \
+ if (i_eq((&r), (&val))) \
prev = _cx_memb(_erase_after_)(self, prev), ++n; \
else \
prev = (node == self->last ? NULL : node); \
diff --git a/include/stc/clist.h b/include/stc/clist.h index 7b56bae4..eec795cf 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -287,7 +287,7 @@ STC_DEF _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw val) {
c_foreach (it, _cx_self, it1, it2) {
i_valraw r = i_valto(it.ref);
- if (!(i_cmp((&r), (&val)))) return it;
+ if (i_eq((&r), (&val))) return it;
}
it2.ref = NULL; return it2;
}
@@ -299,7 +299,7 @@ _cx_memb(_remove)(_cx_self* self, i_valraw val) { while (prev) {
node = prev->next;
i_valraw r = i_valto((&node->value));
- if (!(i_cmp((&r), (&val))))
+ if (i_eq((&r), (&val)))
prev = _cx_memb(_erase_after_)(self, prev), ++n;
else
prev = (node == self->last ? NULL : node);
diff --git a/include/stc/template.h b/include/stc/template.h index 53443308..243eec6f 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -217,7 +217,7 @@ #define i_valdrop c_default_drop
#endif
#if !defined i_eq && defined i_cmp
- #define i_eq !i_cmp
+ #define i_eq(x, y) !(i_cmp(x, y))
#elif !defined i_eq
#define i_eq c_default_eq
#endif
|
