summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-09-17 20:10:35 +0200
committerTyge Løvset <[email protected]>2021-09-17 20:10:35 +0200
commitf8673fa5250d47789c3d66b52aacd1be65ced619 (patch)
tree4520443ce0abd4863e6ed1c639667011cbf6360c
parent0d252463192cf3391d9c41e47574a560b7377bee (diff)
downloadSTC-modified-f8673fa5250d47789c3d66b52aacd1be65ced619.tar.gz
STC-modified-f8673fa5250d47789c3d66b52aacd1be65ced619.zip
Added back (carr3) carray3 in demos.c.
-rw-r--r--docs/csmap_api.md4
-rw-r--r--examples/demos.c40
2 files changed, 23 insertions, 21 deletions
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index 338758ce..143da587 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -16,8 +16,8 @@ See the c++ class [std::map](https://en.cppreference.com/w/cpp/container/map) fo
```c
#define i_tag // defaults to i_key name
-#define i_key // value: REQUIRED
-#define i_val // key: REQUIRED
+#define i_key // key: REQUIRED
+#define i_val // value: REQUIRED
#define i_cmp // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
#define i_keyraw // convertion "raw" type - defaults to i_key
#define i_keyfrom // convertion func i_keyraw => i_key - defaults to plain copy
diff --git a/examples/demos.c b/examples/demos.c
index 4c79e357..03bba7a8 100644
--- a/examples/demos.c
+++ b/examples/demos.c
@@ -185,32 +185,34 @@ void mapdemo3()
cmap_str_del(&table); // frees key and value cstrs, and hash table.
}
-/*
-#include <stc/carray.h>
-using_carray3(f, float);
+//#define i_prefix carray3 // backward compatible.
+#define i_tag f
+#define i_val float
+#include <stc/carr3.h>
void arraydemo1()
{
printf("\nARRAYDEMO1\n");
- carray3f arr3 = carray3f_with_values(30, 20, 10, 0.0f);
- arr3.data[5][4][3] = 10.2f;
- float **arr2 = arr3.data[5];
- float *arr1 = arr3.data[5][4];
-
- printf("arr3: %zu: (%zu, %zu, %zu) = %zu\n", sizeof(arr3), arr3.xdim, arr3.ydim, arr3.zdim, carray3f_size(arr3));
+ c_forvar (carr3_f arr3 = carr3_f_with_values(30, 20, 10, 0.0f),
+ carr3_f_del(&arr3))
+ {
+ arr3.data[5][4][3] = 10.2f;
+ float **arr2 = arr3.data[5];
+ float *arr1 = arr3.data[5][4];
- printf("%g\n", arr1[3]); // = 10.2
- printf("%g\n", arr2[4][3]); // = 10.2
- printf("%g\n", arr3.data[5][4][3]); // = 10.2
+ printf("arr3: %zu: (%zu, %zu, %zu) = %zu\n", sizeof(arr3),
+ arr3.xdim, arr3.ydim, arr3.zdim, carr3_f_size(arr3));
- float x = 0.0;
- c_foreach (i, carray3f, arr3)
- *i.ref = ++x;
- printf("%g\n", arr3.data[29][19][9]); // = 6000
+ printf("%g\n", arr1[3]); // = 10.2
+ printf("%g\n", arr2[4][3]); // = 10.2
+ printf("%g\n", arr3.data[5][4][3]); // = 10.2
- carray3f_del(&arr3);
+ float x = 0.0;
+ c_foreach (i, carr3_f, arr3)
+ *i.ref = ++x;
+ printf("%g\n", arr3.data[29][19][9]); // = 6000
+ }
}
-*/
int main()
@@ -223,5 +225,5 @@ int main()
mapdemo1();
mapdemo2();
mapdemo3();
- //arraydemo1();
+ arraydemo1();
}