diff options
| author | Tyge Løvset <[email protected]> | 2023-02-18 07:51:44 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-18 07:51:44 +0100 |
| commit | 0e3d07dbd991c1f1a691b24655c37ddab660a9d9 (patch) | |
| tree | dc9801e2fc9f62cbe3eb32cc8897c65e3f25f78b /misc/examples | |
| parent | c4ae61de5be08e719e3183f4e2d1115c11856796 (diff) | |
| download | STC-modified-0e3d07dbd991c1f1a691b24655c37ddab660a9d9.tar.gz STC-modified-0e3d07dbd991c1f1a691b24655c37ddab660a9d9.zip | |
Fixed carc, cbox: no need for no_lookup and no_eq: use only no_cmp, no_hash if needed.
Diffstat (limited to 'misc/examples')
| -rw-r--r-- | misc/examples/arc_containers.c | 2 | ||||
| -rw-r--r-- | misc/examples/box2.c | 6 | ||||
| -rw-r--r-- | misc/examples/list.c | 2 | ||||
| -rw-r--r-- | misc/examples/music_arc.c | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/misc/examples/arc_containers.c b/misc/examples/arc_containers.c index 201c73d5..b621c386 100644 --- a/misc/examples/arc_containers.c +++ b/misc/examples/arc_containers.c @@ -12,7 +12,7 @@ #define i_val Map #define i_valdrop(p) (printf("drop Arc:\n"), Map_drop(p)) // no need for atomic ref. count in single thread: -#define i_opt c_no_atomic|c_no_lookup|c_no_clone +#define i_opt c_no_atomic|c_no_cmp|c_no_clone #include <stc/carc.h> #define i_type Stack diff --git a/misc/examples/box2.c b/misc/examples/box2.c index b9628eeb..943b2ae8 100644 --- a/misc/examples/box2.c +++ b/misc/examples/box2.c @@ -18,18 +18,18 @@ struct { } typedef Rectangle; #define i_val Point -#define i_opt c_no_lookup +#define i_opt c_no_cmp #include <stc/cbox.h> // cbox_Point #define i_val Rectangle -#define i_opt c_no_lookup +#define i_opt c_no_cmp #include <stc/cbox.h> // cbox_Rectangle // Box in box: #define i_valboxed cbox_Point // NB: use i_valboxed when value is a cbox or carc! // it will auto define i_valdrop, i_valfrom, and i_cmp. #define i_tag BoxPoint -#define i_opt c_no_lookup +#define i_opt c_no_cmp #include <stc/cbox.h> // cbox_BoxPoint Point origin(void) { diff --git a/misc/examples/list.c b/misc/examples/list.c index 79dcfcaf..6a655800 100644 --- a/misc/examples/list.c +++ b/misc/examples/list.c @@ -30,7 +30,7 @@ int main() { clist_fx_sort(&list); // mergesort O(n*log n) puts("sorted"); - int last = 0; + double last = 0; c_foreach (i, clist_fx, list) { if (*i.ref < last) {printf("ERROR"); exit(-1);} last = *i.ref; diff --git a/misc/examples/music_arc.c b/misc/examples/music_arc.c index 2a2d24c5..fcd24beb 100644 --- a/misc/examples/music_arc.c +++ b/misc/examples/music_arc.c @@ -11,6 +11,8 @@ typedef struct int Song_cmp(const Song* x, const Song* y) { return cstr_cmp(&x->title, &y->title); } +uint64_t Song_hash(const Song* x) { return cstr_hash(&x->title); } + Song Song_make(const char* artist, const char* title) { return (Song){cstr_from(artist), cstr_from(title)}; } @@ -22,7 +24,7 @@ void Song_drop(Song* s) { // Define the reference counted type #define i_type SongArc #define i_valclass Song -#define i_opt c_no_hash +//#define i_opt c_no_hash #include <stc/carc.h> // ... and a vector of it |
