summaryrefslogtreecommitdiffhomepage
path: root/examples/complex.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-02 19:49:51 +0200
committerTyge Løvset <[email protected]>2020-09-02 19:49:51 +0200
commitaf12926547b1a09b4513ba149d13ea9f84d4c528 (patch)
tree954ab763d10a2c5558163645004b9c11ed63b5d1 /examples/complex.c
parent1b46028f4636c78af40c37dbc55d76598996a5b7 (diff)
downloadSTC-modified-af12926547b1a09b4513ba149d13ea9f84d4c528.tar.gz
STC-modified-af12926547b1a09b4513ba149d13ea9f84d4c528.zip
Added cqueue.h and cstack.h adapters. Updated cpqueue.h API to be more consistent.
Diffstat (limited to 'examples/complex.c')
-rw-r--r--examples/complex.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/complex.c b/examples/complex.c
index 08a3b505..8810bac5 100644
--- a/examples/complex.c
+++ b/examples/complex.c
@@ -6,32 +6,32 @@
void check_destroy(float* v) {printf("destroy %g\n", *v);}
declare_carray(f, float, check_destroy); // normally omit the last argument - float type need no destroy.
-declare_clist(t2, carray2f, carray2f_destroy, c_no_compare);
-declare_cmap(il, int, clist_t2, clist_t2_destroy);
-declare_cmap_strkey(sm, cmap_il, cmap_il_destroy);
+declare_clist(y, carray2f, carray2f_destroy, c_no_compare);
+declare_cmap(g, int, clist_y, clist_y_destroy);
+declare_cmap_strkey(s, cmap_g, cmap_g_destroy);
int main() {
int xdim = 4, ydim = 6;
int x = 1, y = 5, tableKey = 42;
const char* strKey = "first";
- cmap_sm theMap = cmap_init;
+ cmap_s myMap = cmap_init;
{ // Construct.
carray2f table = carray2f_make(ydim, xdim, 0.f);
printf("table: (%zu, %zu)\n", carray2_ydim(table), carray2_xdim(table));
- clist_t2 tableList = clist_init;
+ clist_y tableList = clist_init;
// Put in some data.
- cmap_il listMap = cmap_init;
+ cmap_g listMap = cmap_init;
*carray2f_at(&table, y, x) = 3.1415927; // table[y][x]
- clist_t2_push_back(&tableList, table);
- cmap_il_put(&listMap, tableKey, tableList);
- cmap_sm_put(&theMap, strKey, listMap);
+ clist_y_push_back(&tableList, table);
+ cmap_g_put(&listMap, tableKey, tableList);
+ cmap_s_put(&myMap, strKey, listMap);
}
{ // Access the data entry
- carray2f table = clist_back(cmap_il_find(&cmap_sm_find(&theMap, strKey)->value, tableKey)->value);
+ carray2f table = *clist_y_back(&cmap_g_find(&cmap_s_find(&myMap, strKey)->value, tableKey)->value);
printf("value (%d, %d) is: %f\n", y, x, *carray2f_at(&table, y, x));
}
- cmap_sm_destroy(&theMap); // free up the whole shebang!
+ c_destroy(cmap_s, &myMap); // free up everything!
} \ No newline at end of file