summaryrefslogtreecommitdiffhomepage
path: root/examples/list.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-15 22:43:41 +0200
committerTyge Løvset <[email protected]>2020-09-15 22:43:41 +0200
commitf4435af2fc9e9187f7be0149c2eb916db27cb257 (patch)
tree117429619290d165b7a3001f21f3c0e7f37a1045 /examples/list.c
parentf539099575e14aea9f2e043b9af33d05c47399ad (diff)
downloadSTC-modified-f4435af2fc9e9187f7be0149c2eb916db27cb257.tar.gz
STC-modified-f4435af2fc9e9187f7be0149c2eb916db27cb257.zip
New API Change.
Diffstat (limited to 'examples/list.c')
-rw-r--r--examples/list.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/list.c b/examples/list.c
index d140d103..c77be371 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -2,7 +2,7 @@
#include <time.h>
#include <stc/clist.h>
#include <stc/crandom.h>
-declare_clist(fx, double);
+cdef_clist(fx, double);
int main() {
int k, n = 100000;
@@ -13,18 +13,18 @@ int main() {
for (int i = 0; i < 100000; ++i)
clist_fx_push_back(&list, crand_uniform_f64(&eng, &dist));
k = 0; c_foreach (i, clist_fx, list)
- if (++k <= 10) printf("%8d: %10f\n", k, i.item->value); else break;
+ if (++k <= 10) printf("%8d: %10f\n", k, i.get->value); else break;
clist_fx_sort(&list); // mergesort O(n*log n)
puts("sorted");
k = 0; c_foreach (i, clist_fx, list)
- if (++k <= 10) printf("%8d: %10f\n", k, i.item->value); else break;
+ if (++k <= 10) printf("%8d: %10f\n", k, i.get->value); else break;
puts("");
clist_fx_clear(&list);
c_push(&list, clist_fx, {10, 20, 30, 40, 30, 50});
- c_foreach (i, clist_fx, list) printf(" %g", i.item->value);
+ c_foreach (i, clist_fx, list) printf(" %g", i.get->value);
puts("");
int removed = clist_fx_remove(&list, 30);
@@ -34,11 +34,11 @@ int main() {
clist_fx_iter_t it = clist_fx_before_begin(&list);
printf("Full: ");
c_foreach (i, clist_fx, list)
- printf(" %g", i.item->value);
+ printf(" %g", i.get->value);
for (int i=0; i<4; ++i) clist_fx_next(&it);
printf("\nSubs: ");
c_foreach (i, clist_fx, it, clist_fx_end(&list))
- printf(" %g", i.item->value);
+ printf(" %g", i.get->value);
puts("");
clist_fx_destroy(&list);
} \ No newline at end of file