diff options
| author | Tyge Lovset <[email protected]> | 2022-12-20 23:31:51 +0100 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2022-12-20 23:31:51 +0100 |
| commit | 5f57d597cd27aef55adbcb3b452973b0c6e33667 (patch) | |
| tree | dfd59c2fd0e36a6ef37912a9d0cc5a65970f1524 /examples/complex.c | |
| parent | 1763be8c8cbbc0896477fcf924edd4180d1345a9 (diff) | |
| download | STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.tar.gz STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.zip | |
Restructured folders: examples, benchmarks, tests into misc folder.
Diffstat (limited to 'examples/complex.c')
| -rw-r--r-- | examples/complex.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/examples/complex.c b/examples/complex.c deleted file mode 100644 index dd2f951a..00000000 --- a/examples/complex.c +++ /dev/null @@ -1,55 +0,0 @@ - -// Define similar c++ data types: -// -// using FloatStack = std::stack<float>; -// using StackList = std::stack<FloatStack>; -// using ListMap = std::unordered_map<int, std::forward_list<StackList>>; -// using MapMap = std::unordered_map<std::string, ListMap>; - -#include <stc/cstr.h> - - -#define i_type FloatStack -#define i_val float -#include <stc/cstack.h> - -#define i_type StackList -#define i_valclass FloatStack // "class" picks up _clone, _drop -#define i_opt c_no_cmp // no FloatStack_cmp() -#include <stc/clist.h> - -#define i_type ListMap -#define i_key int -#define i_valclass StackList // "class" picks up _clone, _drop -#include <stc/cmap.h> - -#define i_type MapMap -#define i_key_str -#define i_valclass ListMap -#include <stc/cmap.h> - - -int main() -{ - c_auto (MapMap, mmap) - { - FloatStack stack = FloatStack_with_size(10, 0); - - // Put in some data in the structures - stack.data[3] = 3.1415927f; - printf("stack size: %" c_ZU "\n", FloatStack_size(&stack)); - - StackList list = StackList_init(); - StackList_push_back(&list, stack); - - ListMap lmap = ListMap_init(); - ListMap_insert(&lmap, 42, list); - MapMap_insert(&mmap, cstr_from("first"), lmap); - - // Access the data entry - const ListMap* lmap_p = MapMap_at(&mmap, "first"); - const StackList* list_p = ListMap_at(lmap_p, 42); - const FloatStack* stack_p = StackList_back(list_p); - printf("value is: %f\n", *FloatStack_at(stack_p, 3)); // pi - } -} |
