summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-06-22 22:09:00 +0200
committerGitHub <[email protected]>2020-06-22 22:09:00 +0200
commit8af243365bfcc5c60155476adf7e4bd677893b0d (patch)
tree21d1769edaeefc8b70c4dd363e92ec2d80435a6d
parent2eb4543b148daa49dae229f6ddf11b8bc354cfd6 (diff)
downloadSTC-modified-8af243365bfcc5c60155476adf7e4bd677893b0d.tar.gz
STC-modified-8af243365bfcc5c60155476adf7e4bd677893b0d.zip
Update README.md
-rw-r--r--README.md15
1 files changed, 8 insertions, 7 deletions
diff --git a/README.md b/README.md
index 35cf4485..f7f94b50 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ Also look at **examples/advanced.c**, it demonstrates how to use a custom struct
Demos
-----
-The first example has a complex nested container type, which demonstrates some of the capabilities of the library. Look at the simpler examples below to understand it better. The example adds an element into the data structure, and then accesses it. The type used, with c++ template syntax is:
+The first example has a very complex nested container type, which demonstrates the power of this library. Look at the simpler examples below to understand it better. The example adds an element into the data structure, and then accesses it. The type used, with c++ template syntax is:
**CHashMap**< **CString**, **CHashMap**< *int*, **CList**< **CArray2**< *float* >>>>
Note: The *chash_sm_destroy(&theMap)* call below, will destroy all the nested containers including the memory allocated for CString keys in theMap object.
@@ -141,24 +141,25 @@ declare_CHash(il, MAP, int, CList_t2, clist_t2_destroy);
declare_CHash_string(sm, MAP, CHash_lm, chash_lm_destroy);
int main() {
- int dim1 = 4, dim2 = 6;
+ int xdim = 4, ydim = 6;
+ int x = 2, y = 5, entry = 42;
CHash_sm theMap = chash_init;
{
// Construct.
- CArray2_f table = carray2_f_make(dim1, dim2, 0.f);
+ CArray2_f table = carray2_f_make(xdim, ydim, 0.f);
CList_t2 tableList = clist_init;
CHash_il listMap = chash_init;
// Put in some data.
- carray2_f_data(table, 2)[5] = 3.1415927; // table[2][5]
+ carray2_f_data(table, x)[y] = 3.1415927; // table[x][y]
clist_t2_pushBack(&tableList, table);
- chash_il_put(&listMap, 42, tableList);
+ chash_il_put(&listMap, entry, tableList);
chash_sm_put(&theMap, "First", listMap);
}
// Access the data entry
- CArray2_f table = clist_back(chash_il_get(&chash_sm_get(&theMap, "First")->value, 42)->value);
- printf("value is: %f\n", carray2_f_value(table, 3, 5));
+ CArray2_f table = clist_back(chash_il_get(&chash_sm_get(&theMap, "First")->value, entry)->value);
+ printf("value is: %f\n", carray2_f_value(table, x, y));
chash_sm_destroy(&theMap); // free up the whole shebang!
}