diff options
| author | Tyge Løvset <[email protected]> | 2023-08-10 21:17:48 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-08-10 21:17:48 +0200 |
| commit | be5651c9fc3d3ecd2d9d24e6e4763260ef86de41 (patch) | |
| tree | c9e9f5bc6814716b4faac75833cc1ecc1371c8c5 /misc/examples/smartpointers | |
| parent | c27c266b6c4ae0e5e535b18c3790ee97416412b9 (diff) | |
| download | STC-modified-be5651c9fc3d3ecd2d9d24e6e4763260ef86de41.tar.gz STC-modified-be5651c9fc3d3ecd2d9d24e6e4763260ef86de41.zip | |
Update template.h - also renamed i_cmp_native => i_use_cmp
Diffstat (limited to 'misc/examples/smartpointers')
| -rw-r--r-- | misc/examples/smartpointers/arc_containers.c | 4 | ||||
| -rw-r--r-- | misc/examples/smartpointers/arc_demo.c | 3 | ||||
| -rw-r--r-- | misc/examples/smartpointers/arcvec_erase.c | 3 | ||||
| -rw-r--r-- | misc/examples/smartpointers/box.c | 1 | ||||
| -rw-r--r-- | misc/examples/smartpointers/box2.c | 1 | ||||
| -rw-r--r-- | misc/examples/smartpointers/music_arc.c | 4 | ||||
| -rw-r--r-- | misc/examples/smartpointers/new_sptr.c | 3 | ||||
| -rw-r--r-- | misc/examples/smartpointers/person_arc.c | 3 |
8 files changed, 13 insertions, 9 deletions
diff --git a/misc/examples/smartpointers/arc_containers.c b/misc/examples/smartpointers/arc_containers.c index 6209005d..c2bff56f 100644 --- a/misc/examples/smartpointers/arc_containers.c +++ b/misc/examples/smartpointers/arc_containers.c @@ -12,11 +12,11 @@ #define i_key Map #define i_keydrop(p) (printf("drop Arc:\n"), Map_drop(p)) // no need for atomic ref. count in single thread: -#define i_opt c_no_atomic +#define i_opt c_no_atomic|c_no_cmp #include <stc/carc.h> #define i_type Stack -#define i_keyboxed Arc // define i_keyboxed for carc/cbox value (not i_key) +#define i_keyboxed Arc // use i_keyboxed for carc/cbox key #include <stc/cvec.h> #define i_type List diff --git a/misc/examples/smartpointers/arc_demo.c b/misc/examples/smartpointers/arc_demo.c index 929a48a1..a66d84b0 100644 --- a/misc/examples/smartpointers/arc_demo.c +++ b/misc/examples/smartpointers/arc_demo.c @@ -11,13 +11,14 @@ void int_drop(int* x) { #define i_type Arc // set type name to be defined (instead of 'carc_int') #define i_key int #define i_keydrop int_drop // optional, just to display the elements destroyed -#define i_cmp_native // use int comparison (x < y, x == y). +#define i_use_cmp // use int comparison (x < y, x == y). #include <stc/carc.h> // Arc #define i_keyboxed Arc // note: use i_keyboxed instead of i_key for carc/cbox elements #include <stc/csset.h> // csset_Arc (like: std::set<std::shared_ptr<int>>) #define i_keyboxed Arc // note: as above. +#define i_use_cmp #include <stc/cvec.h> // cvec_Arc (like: std::vector<std::shared_ptr<int>>) int main(void) diff --git a/misc/examples/smartpointers/arcvec_erase.c b/misc/examples/smartpointers/arcvec_erase.c index 9d757533..0526b6a0 100644 --- a/misc/examples/smartpointers/arcvec_erase.c +++ b/misc/examples/smartpointers/arcvec_erase.c @@ -5,11 +5,12 @@ void show_drop(int* x) { printf("drop: %d\n", *x); } #define i_type Arc #define i_key int #define i_keydrop show_drop -#define i_cmp_native // enable sort/search for int type +#define i_use_cmp // enable sort/search for int type #include <stc/carc.h> // Shared pointer to int #define i_type Vec #define i_keyboxed Arc +#define i_use_cmp #include <stc/cvec.h> // Vec: cvec<Arc> diff --git a/misc/examples/smartpointers/box.c b/misc/examples/smartpointers/box.c index 94d126c0..5c8018d4 100644 --- a/misc/examples/smartpointers/box.c +++ b/misc/examples/smartpointers/box.c @@ -30,6 +30,7 @@ void Person_drop(Person* p) { #define i_type PBox #define i_keyclass Person // "class" binds _cmp, _clone, _drop functions. +#define i_use_cmp #include <stc/cbox.h> #define i_type Persons diff --git a/misc/examples/smartpointers/box2.c b/misc/examples/smartpointers/box2.c index eaab1c47..9b782c74 100644 --- a/misc/examples/smartpointers/box2.c +++ b/misc/examples/smartpointers/box2.c @@ -22,7 +22,6 @@ typedef struct { // Box in box: #define i_type BoxBoxPoint #define i_keyboxed cbox_Point // NB: use i_keyboxed when value is a cbox or carc! -#define i_no_cmp #include <stc/cbox.h> // BoxBoxPoint Point origin(void) { diff --git a/misc/examples/smartpointers/music_arc.c b/misc/examples/smartpointers/music_arc.c index 13d368c3..e9ebbbfe 100644 --- a/misc/examples/smartpointers/music_arc.c +++ b/misc/examples/smartpointers/music_arc.c @@ -23,7 +23,7 @@ void Song_drop(Song* s) { // Define the shared pointer: #define i_type SongArc #define i_keyclass Song -#define i_no_hash // no hash fn for Song, fallback hash pointer to Song. +#define i_opt c_use_cmp|c_no_hash #include <stc/carc.h> // ... and a vector of them @@ -64,4 +64,4 @@ void example3(void) int main(void) { example3(); -} +}
\ No newline at end of file diff --git a/misc/examples/smartpointers/new_sptr.c b/misc/examples/smartpointers/new_sptr.c index 3c6fa16c..50e28ae2 100644 --- a/misc/examples/smartpointers/new_sptr.c +++ b/misc/examples/smartpointers/new_sptr.c @@ -10,12 +10,13 @@ uint64_t Person_hash(const Person* p); #define i_type PersonArc #define i_keyclass Person // "class" assume _clone, _drop, _cmp, _hash is defined. +#define i_use_cmp #include <stc/carc.h> #define i_type IPtr #define i_key int #define i_keydrop(x) printf("drop: %d\n", *x) -#define i_cmp_native +#define i_use_cmp #include <stc/carc.h> #define i_type IPStack diff --git a/misc/examples/smartpointers/person_arc.c b/misc/examples/smartpointers/person_arc.c index 38c883a7..11040cd2 100644 --- a/misc/examples/smartpointers/person_arc.c +++ b/misc/examples/smartpointers/person_arc.c @@ -31,11 +31,12 @@ void Person_drop(Person* p) { #define i_type PSPtr #define i_keyclass Person // ensure Person_drop -#define i_cmp Person_cmp // specify object cmp, instead of ptr cmp for arc. +#define i_use_cmp #include <stc/carc.h> #define i_type Persons #define i_keyboxed PSPtr // binds PSPtr_cmp, PSPtr_drop... +#define i_use_cmp #include <stc/cvec.h> |
