diff options
| author | Tyge Løvset <[email protected]> | 2021-09-08 16:09:37 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-09-08 16:09:37 +0200 |
| commit | 3868683b6131469a66e365496f93e5a8564e309a (patch) | |
| tree | 5b0eb832afb18f222956c6ea2458788d4af86e9d /examples | |
| parent | ef9697b470d6b2a6d210a1f7439c3d4d6da9d7ee (diff) | |
| download | STC-modified-3868683b6131469a66e365496f93e5a8564e309a.tar.gz STC-modified-3868683b6131469a66e365496f93e5a8564e309a.zip | |
Adjusted demos.c and multimap.c to work with newstyle branch.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demos.c | 49 | ||||
| -rw-r--r-- | examples/multimap.c | 16 |
2 files changed, 37 insertions, 28 deletions
diff --git a/examples/demos.c b/examples/demos.c index bb4deb22..4c79e357 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -1,11 +1,5 @@ -#include <stc/cvec.h>
-#include <stc/clist.h>
-#include <stc/carray.h>
-#include <stc/cset.h>
-#include <stc/cmap.h>
#include <stc/cstr.h>
-
void stringdemo1()
{
printf("\nSTRINGDEMO1\n");
@@ -34,8 +28,9 @@ void stringdemo1() }
}
-
-using_cvec(ix, int64_t); // ix is just an example tag name.
+#define i_tag ix
+#define i_val int64_t
+#include <stc/cvec.h>
void vectordemo1()
{
@@ -58,8 +53,8 @@ void vectordemo1() }
}
-
-using_cvec_str();
+#define i_val_str
+#include <stc/cvec.h>
void vectordemo2()
{
@@ -77,7 +72,9 @@ void vectordemo2() }
}
-using_clist(ix, int);
+#define i_tag ix
+#define i_val int
+#include <stc/clist.h>
void listdemo1()
{
@@ -99,7 +96,7 @@ void listdemo1() *clist_ix_find(&nums, 104).ref += 50;
clist_ix_remove(&nums, 103);
clist_ix_iter_t it = clist_ix_begin(&nums);
- clist_ix_erase_range(&nums, clist_ix_fwd(it, 5), clist_ix_fwd(it, 15));
+ clist_ix_erase_range(&nums, clist_ix_advance(it, 5), clist_ix_advance(it, 15));
clist_ix_pop_front(&nums);
clist_ix_push_back(&nums, -99);
clist_ix_sort(&nums);
@@ -109,7 +106,9 @@ void listdemo1() }
}
-using_cset(i, int);
+#define i_tag i
+#define i_key int
+#include <stc/cset.h>
void setdemo1()
{
@@ -123,8 +122,10 @@ void setdemo1() cset_i_del(&nums);
}
-
-using_cmap(ii, int, int);
+#define i_tag ii
+#define i_key int
+#define i_val int
+#include <stc/cmap.h>
void mapdemo1()
{
@@ -136,8 +137,10 @@ void mapdemo1() cmap_ii_del(&nums);
}
-
-using_cmap_strkey(si, int); // Shorthand macro for the general using_cmap expansion.
+#define i_tag si
+#define i_key_str
+#define i_val int
+#include <stc/cmap.h>
void mapdemo2()
{
@@ -158,8 +161,9 @@ void mapdemo2() }
}
-
-using_cmap_str();
+#define i_key_str
+#define i_val_str
+#include <stc/cmap.h>
void mapdemo3()
{
@@ -181,7 +185,8 @@ void mapdemo3() cmap_str_del(&table); // frees key and value cstrs, and hash table.
}
-
+/*
+#include <stc/carray.h>
using_carray3(f, float);
void arraydemo1()
@@ -205,7 +210,7 @@ void arraydemo1() carray3f_del(&arr3);
}
-
+*/
int main()
@@ -218,5 +223,5 @@ int main() mapdemo1();
mapdemo2();
mapdemo3();
- arraydemo1();
+ //arraydemo1();
}
diff --git a/examples/multimap.c b/examples/multimap.c index 03d4712d..eeb7a501 100644 --- a/examples/multimap.c +++ b/examples/multimap.c @@ -1,5 +1,3 @@ -#include <stc/csmap.h>
-#include <stc/clist.h>
#include <stc/cstr.h>
#include <stdio.h>
@@ -35,7 +33,6 @@ struct OlympicsData { int year; const char *city, *country, *date; } ol_data[] = {1924, "Chamonix", "France", "January 25 - February 5"},
};
-
typedef struct { int year; cstr city, date; } OlympicLocation;
int OlympicLocation_compare(OlympicLocation* a, OlympicLocation* b) {
@@ -46,11 +43,18 @@ void OlympicLocation_del(OlympicLocation* self) { }
// Create a clist<OlympicLocation>, can be sorted by year.
-using_clist(OL, OlympicLocation, OlympicLocation_compare, OlympicLocation_del);
+#define i_tag OL
+#define i_val OlympicLocation
+#define i_cmp OlympicLocation_compare
+#define i_valdel OlympicLocation_del
+#include <stc/clist.h>
// Create a csmap<cstr, clist_OL> where key is country
-using_csmap_strkey(OL, clist_OL, clist_OL_del, c_no_clone);
-
+#define i_tag OL
+#define i_key_str
+#define i_val clist_OL
+#define i_valdel clist_OL_del
+#include <stc/csmap.h>
int main()
{
|
