diff options
| author | Tyge Løvset <[email protected]> | 2020-09-18 11:55:29 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-09-18 11:55:29 +0200 |
| commit | 681873e4cb6ea076b79c6c70b2df2ba4e4c19bda (patch) | |
| tree | 69c0c3290189163937d4ab4203fe4565094657b0 /examples | |
| parent | 692ab82818e2d65177e06d7717d9184b7bc27ff1 (diff) | |
| download | STC-modified-681873e4cb6ea076b79c6c70b2df2ba4e4c19bda.tar.gz STC-modified-681873e4cb6ea076b79c6c70b2df2ba4e4c19bda.zip | |
Changed <container>_ini macro constant to <container>_INIT, and <container>_destroy() to <container>_del.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/README.md | 16 | ||||
| -rw-r--r-- | examples/advanced.c | 16 | ||||
| -rw-r--r-- | examples/benchmark.c | 6 | ||||
| -rw-r--r-- | examples/birthday.c | 2 | ||||
| -rw-r--r-- | examples/bits.c | 6 | ||||
| -rw-r--r-- | examples/complex.c | 18 | ||||
| -rw-r--r-- | examples/demos.c | 34 | ||||
| -rw-r--r-- | examples/ex_gaussian.c | 14 | ||||
| -rw-r--r-- | examples/heap.c | 2 | ||||
| -rw-r--r-- | examples/inits.c | 26 | ||||
| -rw-r--r-- | examples/list.c | 4 | ||||
| -rw-r--r-- | examples/mapmap.c | 8 | ||||
| -rw-r--r-- | examples/phonebook.c | 4 | ||||
| -rw-r--r-- | examples/prime.c | 2 | ||||
| -rw-r--r-- | examples/priority.c | 2 | ||||
| -rw-r--r-- | examples/queue.c | 4 | ||||
| -rw-r--r-- | examples/random.c | 4 | ||||
| -rw-r--r-- | examples/replace.c | 2 | ||||
| -rw-r--r-- | examples/words.c | 10 |
19 files changed, 90 insertions, 90 deletions
diff --git a/examples/README.md b/examples/README.md index 95880385..74ac4384 100644 --- a/examples/README.md +++ b/examples/README.md @@ -39,9 +39,9 @@ typedef struct Viking { } Viking;
-void viking_destroy(Viking* vk) {
- cstr_destroy(&vk->name);
- cstr_destroy(&vk->country);
+void viking_del(Viking* vk) {
+ cstr_del(&vk->name);
+ cstr_del(&vk->country);
}
static inline VikingVw viking_toVw(Viking* vk) {
@@ -53,14 +53,14 @@ static inline Viking viking_fromVw(VikingVw vw) { // note: parameter is by value ```
With this in place, we use the full using_cmap() macro to define {Viking -> int} hash map type:
```
-using_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
- viking_destroy, VikingVw, viking_toVw, viking_fromVw);
+using_cmap(vk, Viking, int, c_default_del, vikingvw_equals, vikingvw_hash,
+ viking_del, VikingVw, viking_toVw, viking_fromVw);
```
-cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. cmap_vk_destroy() will free all memory allocated for Viking keys and the hash table values.
+cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. cmap_vk_del() will free all memory allocated for Viking keys and the hash table values.
Finally, main which also demos the generic c_push_items() of multiple elements:
```
int main() {
- cmap_vk vikings = cmap_ini;
+ cmap_vk vikings = cmap_INIT;
c_push_items(&vikings, cmap_vk, {
{ {"Einar", "Norway"}, 20 },
{ {"Olaf", "Denmark"}, 24 },
@@ -74,6 +74,6 @@ int main() { c_foreach (k, cmap_vk, vikings) {
printf("%s of %s has %d hp\n", k.get->key.name.str, k.get->key.country.str, k.get->value);
}
- cmap_vk_destroy(&vikings);
+ cmap_vk_del(&vikings);
}
```
diff --git a/examples/advanced.c b/examples/advanced.c index 200ab5a3..7cf55d2c 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -22,9 +22,9 @@ typedef struct Viking { } Viking; -void viking_destroy(Viking* vk) { - cstr_destroy(&vk->name); - cstr_destroy(&vk->country); +void viking_del(Viking* vk) { + cstr_del(&vk->name); + cstr_del(&vk->country); } // Viking view struct ----------------------- @@ -51,17 +51,17 @@ Viking viking_fromVw(VikingVw vw) { } // Using the full using_cmap() macro to define [Viking -> int] hash map type: -using_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash, - viking_destroy, VikingVw, viking_toVw, viking_fromVw); +using_cmap(vk, Viking, int, c_default_del, vikingvw_equals, vikingvw_hash, + viking_del, VikingVw, viking_toVw, viking_fromVw); // cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. -// cmap_vk_destroy() will free all memory allocated for Viking keys and the hash table values. +// cmap_vk_del() will free all memory allocated for Viking keys and the hash table values. // Main ---------------------------- int main() { - cmap_vk vikings = cmap_ini; + cmap_vk vikings = cmap_INIT; c_push_items(&vikings, cmap_vk, { {{"Einar", "Norway"}, 20}, {{"Olaf", "Denmark"}, 24}, @@ -76,6 +76,6 @@ int main() c_foreach (k, cmap_vk, vikings) { printf("%s of %s has %d hp\n", k.get->first.name.str, k.get->first.country.str, k.get->second); } - cmap_vk_destroy(&vikings); + cmap_vk_del(&vikings); } diff --git a/examples/benchmark.c b/examples/benchmark.c index a02e8be8..e9719dbf 100644 --- a/examples/benchmark.c +++ b/examples/benchmark.c @@ -22,7 +22,7 @@ static inline uint32_t fibonacci_hash(const void* data, size_t len) { }
// cmap and khash template expansion
-using_cmap(ii, int64_t, int64_t, c_default_destroy, c_default_equals, fibonacci_hash); // c_default_hash16);
+using_cmap(ii, int64_t, int64_t, c_default_del, c_default_equals, fibonacci_hash); // c_default_hash16);
KHASH_MAP_INIT_INT64(ii, int64_t)
@@ -34,7 +34,7 @@ crand_rng64_t rng; #define RAND(N) (crand_i64(&rng) & ((1 << N) - 1))
-#define CMAP_SETUP(X, Key, Value) cmap_##X map = cmap_ini \
+#define CMAP_SETUP(X, Key, Value) cmap_##X map = cmap_INIT \
; cmap_##X##_set_load_factors(&map, max_load_factor, 0.0)
#define CMAP_PUT(X, key, val) cmap_##X##_put(&map, key, val).first->second
#define CMAP_EMPLACE(X, key, val) cmap_##X##_emplace(&map, key, val)
@@ -45,7 +45,7 @@ crand_rng64_t rng; #define CMAP_SIZE(X) cmap_size(map)
#define CMAP_BUCKETS(X) cmap_##X##_bucket_count(map)
#define CMAP_CLEAR(X) cmap_##X##_clear(&map)
-#define CMAP_DTOR(X) cmap_##X##_destroy(&map)
+#define CMAP_DTOR(X) cmap_##X##_del(&map)
#define KMAP_SETUP(X, Key, Value) khash_t(ii)* map = kh_init(ii); khiter_t ki; int ret
#define KMAP_PUT(X, key, val) (*(ki = kh_put(ii, map, key, &ret), map->vals[ki] = val, &map->vals[ki]))
diff --git a/examples/birthday.c b/examples/birthday.c index 7bee3658..59a47bdb 100644 --- a/examples/birthday.c +++ b/examples/birthday.c @@ -16,7 +16,7 @@ const static uint64_t mask = (1ull << 52) - 1; void repeats(void)
{
crand_rng64_t rng = crand_rng64_init(seed);
- cmap_ic m = cmap_ini;
+ cmap_ic m = cmap_INIT;
cmap_ic_reserve(&m, N);
clock_t now = clock();
for (size_t i = 0; i < N; ++i) {
diff --git a/examples/bits.c b/examples/bits.c index 28d1cfff..08b45669 100644 --- a/examples/bits.c +++ b/examples/bits.c @@ -9,7 +9,7 @@ int main() { cbitset_resize(&set, 43, false);
cstr_t str = cbitset_to_str(set);
printf(" str: %s\n", str.str);
- cstr_destroy(&str);
+ cstr_del(&str);
printf("%4zu: ", set.size);
for (int i=0; i<set.size; ++i)
@@ -53,6 +53,6 @@ int main() { printf("%d", cbitset_test(set, i));
puts("");
- cbitset_destroy(&s2);
- cbitset_destroy(&set);
+ cbitset_del(&s2);
+ cbitset_del(&set);
}
\ No newline at end of file diff --git a/examples/complex.c b/examples/complex.c index 12afc47c..001637ef 100644 --- a/examples/complex.c +++ b/examples/complex.c @@ -3,25 +3,25 @@ #include <stc/clist.h>
#include <stc/carray.h>
-void check_destroy(float* v) {printf("destroy %g\n", *v);}
+void check_del(float* v) {printf("destroy %g\n", *v);}
-using_carray(f, float, check_destroy); // normally omit the last argument - float type need no destroy.
-using_clist(y, carray2f, carray2f_destroy, c_no_compare);
-using_cmap(g, int, clist_y, clist_y_destroy);
-using_cmap_strkey(s, cmap_g, cmap_g_destroy);
+using_carray(f, float, check_del); // normally omit the last argument - float type need no destroy.
+using_clist(y, carray2f, carray2f_del, c_no_compare);
+using_cmap(g, int, clist_y, clist_y_del);
+using_cmap_strkey(s, cmap_g, cmap_g_del);
int main() {
int xdim = 4, ydim = 6;
int x = 1, y = 5, tableKey = 42;
const char* strKey = "first";
- cmap_s myMap = cmap_ini;
+ cmap_s myMap = cmap_INIT;
{ // Construct.
carray2f table = carray2f_make(ydim, xdim, 0.f);
printf("table: (%zu, %zu)\n", carray2_ydim(table), carray2_xdim(table));
- clist_y tableList = clist_ini;
+ clist_y tableList = clist_INIT;
// Put in some data.
- cmap_g listMap = cmap_ini;
+ cmap_g listMap = cmap_INIT;
*carray2f_at(&table, y, x) = 3.1415927f; // table[y][x]
clist_y_push_back(&tableList, table);
@@ -33,5 +33,5 @@ int main() { printf("value (%d, %d) is: %f\n", y, x, *carray2f_at(&table, y, x));
}
- c_dtor(cmap_s, &myMap); // free up everything!
+ c_del_(cmap_s, &myMap); // free up everything!
}
\ No newline at end of file diff --git a/examples/demos.c b/examples/demos.c index 6f5c0207..85d96e7e 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -30,7 +30,7 @@ void stringdemo1() cstr_append(&cs, " eight");
printf("append: %s\n", cs.str);
- cstr_destroy(&cs);
+ cstr_del(&cs);
}
@@ -39,7 +39,7 @@ using_cvec(ix, int64_t); // ix is just an example tag name. void vectordemo1()
{
printf("\nVECTORDEMO1\n");
- cvec_ix bignums = cvec_ini; // = (cvec_ix) cvec_ini; if initializing after declaration.
+ cvec_ix bignums = cvec_INIT; // = (cvec_ix) cvec_INIT; if initializing after declaration.
cvec_ix_reserve(&bignums, 100);
for (size_t i = 0; i<=100; ++i)
cvec_ix_push_back(&bignums, i * i * i);
@@ -50,7 +50,7 @@ void vectordemo1() for (size_t i = 0; i < cvec_size(bignums); ++i) {
if (i >= 90) printf("%zu: %zu\n", i, bignums.data[i]);
}
- cvec_ix_destroy(&bignums);
+ cvec_ix_del(&bignums);
}
@@ -60,7 +60,7 @@ using_cvec_str(); void vectordemo2()
{
printf("\nVECTORDEMO2\n");
- cvec_str names = cvec_ini;
+ cvec_str names = cvec_INIT;
cvec_str_emplace_back(&names, "Mary");
cvec_str_emplace_back(&names, "Joe");
cvec_str_emplace_back(&names, "Chris");
@@ -70,7 +70,7 @@ void vectordemo2() cvec_str_sort(&names); // Sort the array
c_foreach (i, cvec_str, names)
printf("sorted: %s\n", i.get->str);
- cvec_str_destroy(&names);
+ cvec_str_del(&names);
}
using_clist(ix, int);
@@ -78,7 +78,7 @@ using_clist(ix, int); void listdemo1()
{
printf("\nLISTDEMO1\n");
- clist_ix nums = clist_ini, nums2 = clist_ini;
+ clist_ix nums = clist_INIT, nums2 = clist_INIT;
for (int i = 0; i < 10; ++i)
clist_ix_push_back(&nums, i);
for (int i = 100; i < 110; ++i)
@@ -97,7 +97,7 @@ void listdemo1() clist_ix_push_front(&nums, -99);
c_foreach (i, clist_ix, nums)
printf("sorted: %d\n", *i.get);
- clist_ix_destroy(&nums);
+ clist_ix_del(&nums);
}
using_cset(i, int);
@@ -105,13 +105,13 @@ using_cset(i, int); void setdemo1()
{
printf("\nSETDEMO1\n");
- cset_i nums = cset_ini;
+ cset_i nums = cset_INIT;
cset_i_insert(&nums, 8);
cset_i_insert(&nums, 11);
c_foreach (i, cset_i, nums)
printf("set: %d\n", *i.get);
- cset_i_destroy(&nums);
+ cset_i_del(&nums);
}
@@ -120,11 +120,11 @@ using_cmap(ii, int, int); void mapdemo1()
{
printf("\nMAPDEMO1\n");
- cmap_ii nums = cmap_ini;
+ cmap_ii nums = cmap_INIT;
cmap_ii_put(&nums, 8, 64);
cmap_ii_put(&nums, 11, 121);
printf("get 8: %d\n", *cmap_ii_at(&nums, 8));
- cmap_ii_destroy(&nums);
+ cmap_ii_del(&nums);
}
@@ -133,7 +133,7 @@ using_cmap_strkey(si, int); // Shorthand macro for the general using_cmap expans void mapdemo2()
{
printf("\nMAPDEMO2\n");
- cmap_si nums = cmap_ini;
+ cmap_si nums = cmap_INIT;
cmap_si_put(&nums, "Hello", 64);
cmap_si_put(&nums, "Groovy", 121);
cmap_si_put(&nums, "Groovy", 200); // overwrite previous
@@ -146,7 +146,7 @@ void mapdemo2() c_foreach (i, cmap_si, nums)
printf("short: %s: %d\n", i.get->first.str, i.get->second);
- cmap_si_destroy(&nums);
+ cmap_si_del(&nums);
}
@@ -155,7 +155,7 @@ using_cmap_str(); void mapdemo3()
{
printf("\nMAPDEMO3\n");
- cmap_str table = cmap_ini;
+ cmap_str table = cmap_INIT;
cmap_str_put(&table, "Map", "test");
cmap_str_put(&table, "Make", "my");
cmap_str_put(&table, "Sunny", "day");
@@ -168,7 +168,7 @@ void mapdemo3() printf("size %zu\n", cmap_size(table));
c_foreach (i, cmap_str, table)
printf("entry: %s: %s\n", i.get->first.str, i.get->second.str);
- cmap_str_destroy(&table); // frees key and value cstrs, and hash table.
+ cmap_str_del(&table); // frees key and value cstrs, and hash table.
}
@@ -193,8 +193,8 @@ void arraydemo1() *i.get = 1.0f;
printf("%f\n", *carray3f_at(&a3, 29, 19, 9));
- carray2f_destroy(&a2); // does nothing, since it is a sub-array.
- carray3f_destroy(&a3); // also invalidates a2.
+ carray2f_del(&a2); // does nothing, since it is a sub-array.
+ carray3f_del(&a3); // also invalidates a2.
}
diff --git a/examples/ex_gaussian.c b/examples/ex_gaussian.c index 033c0ebd..e5dad57a 100644 --- a/examples/ex_gaussian.c +++ b/examples/ex_gaussian.c @@ -14,7 +14,7 @@ static int compare(cmap_i_entry_t *a, cmap_i_entry_t *b) { return c_default_compare(&a->first, &b->first);
}
// Vector: typetag 'e' for (map) entry
-using_cvec(e, cmap_i_entry_t, c_default_destroy, compare);
+using_cvec(e, cmap_i_entry_t, c_default_del, compare);
int main()
{
@@ -29,20 +29,20 @@ int main() crand_normal_f64_t dist = crand_normal_f64_init(Mean, StdDev);
// Create histogram map
- cmap_i mhist = cmap_ini;
+ cmap_i mhist = cmap_INIT;
for (size_t i = 0; i < N; ++i) {
int index = (int) round( crand_normal_f64(&rng, &dist) );
cmap_i_emplace(&mhist, index, 0).first->second += 1;
}
// Transfer map to vec and sort it by map keys.
- cvec_e vhist = cvec_ini;
+ cvec_e vhist = cvec_INIT;
c_foreach (i, cmap_i, mhist)
cvec_e_push_back(&vhist, *i.get);
cvec_e_sort(&vhist);
// Print the gaussian bar chart
- cstr_t bar = cstr_ini;
+ cstr_t bar = cstr_INIT;
c_foreach (i, cvec_e, vhist) {
size_t n = (size_t) (i.get->second * Mag / N);
if (n > 0) {
@@ -52,7 +52,7 @@ int main() }
}
// Cleanup
- cstr_destroy(&bar);
- cmap_i_destroy(&mhist);
- cvec_e_destroy(&vhist);
+ cstr_del(&bar);
+ cmap_i_del(&mhist);
+ cvec_e_del(&vhist);
}
diff --git a/examples/heap.c b/examples/heap.c index 89f700d2..44e9b05e 100644 --- a/examples/heap.c +++ b/examples/heap.c @@ -41,5 +41,5 @@ int main() printf("%.0f ", *cpqueue_f_top(&pq)), cpqueue_f_pop(&pq);
puts("");
- cpqueue_f_destroy(&pq);
+ cpqueue_f_del(&pq);
}
diff --git a/examples/inits.c b/examples/inits.c index c64ca574..14fe8a64 100644 --- a/examples/inits.c +++ b/examples/inits.c @@ -5,7 +5,7 @@ #include <stc/cpqueue.h>
#include <stc/clist.h>
-using_cmap(id, int, cstr_t, cstr_destroy); // Map of int -> cstr_t
+using_cmap(id, int, cstr_t, cstr_del); // Map of int -> cstr_t
using_cmap_strkey(cnt, int);
typedef struct {int x, y;} ipair_t;
@@ -13,8 +13,8 @@ inline static int ipair_compare(const ipair_t* a, const ipair_t* b) { int c = c_default_compare(&a->x, &b->x);
return c != 0 ? c : c_default_compare(&a->y, &b->y);
}
-using_cvec(ip, ipair_t, c_default_destroy, ipair_compare);
-using_clist(ip, ipair_t, c_default_destroy, ipair_compare);
+using_cvec(ip, ipair_t, c_default_del, ipair_compare);
+using_clist(ip, ipair_t, c_default_del, ipair_compare);
using_cvec(f, float);
using_cpqueue(f, cvec_f, >);
@@ -24,7 +24,7 @@ int main(void) { // CVEC FLOAT / PRIORITY QUEUE
- cvec_f floats = cvec_ini;
+ cvec_f floats = cvec_INIT;
c_push_items(&floats, cvec_f, {4.0f, 2.0f, 5.0f, 3.0f, 1.0f});
c_foreach (i, cvec_f, floats) printf("%.1f ", *i.get);
@@ -41,12 +41,12 @@ int main(void) { cpqueue_f_pop(&floats);
}
puts("\n");
- cpqueue_f_destroy(&floats);
+ cpqueue_f_del(&floats);
// CMAP ID
int year = 2020;
- cmap_id idnames = cmap_ini;
+ cmap_id idnames = cmap_INIT;
c_push_items(&idnames, cmap_id, {
{100, cstr("Hello")},
{110, cstr("World")},
@@ -56,11 +56,11 @@ int main(void) { c_foreach (i, cmap_id, idnames)
printf("%d: %s\n", i.get->first, i.get->second.str);
puts("");
- cmap_id_destroy(&idnames);
+ cmap_id_del(&idnames);
// CMAP CNT
- cmap_cnt countries = cmap_ini;
+ cmap_cnt countries = cmap_INIT;
c_push_items(&countries, cmap_cnt, {
{"Norway", 100},
{"Denmark", 50},
@@ -79,11 +79,11 @@ int main(void) { c_foreach (i, cmap_cnt, countries)
printf("%s: %d\n", i.get->first.str, i.get->second);
puts("");
- cmap_cnt_destroy(&countries);
+ cmap_cnt_del(&countries);
// CVEC PAIR
- cvec_ip pairs1 = cvec_ini;
+ cvec_ip pairs1 = cvec_INIT;
c_push_items(&pairs1, cvec_ip, {
{5, 6},
{3, 4},
@@ -95,11 +95,11 @@ int main(void) { c_foreach (i, cvec_ip, pairs1)
printf("(%d %d) ", i.get->x, i.get->y);
puts("");
- cvec_ip_destroy(&pairs1);
+ cvec_ip_del(&pairs1);
// CLIST PAIR
- clist_ip pairs2 = clist_ini;
+ clist_ip pairs2 = clist_INIT;
c_push_items(&pairs2, clist_ip, {
{5, 6},
{3, 4},
@@ -111,5 +111,5 @@ int main(void) { c_foreach (i, clist_ip, pairs2)
printf("(%d %d) ", i.get->x, i.get->y);
puts("");
- clist_ip_destroy(&pairs2);
+ clist_ip_del(&pairs2);
}
\ No newline at end of file diff --git a/examples/list.c b/examples/list.c index abc4d5b7..c2bfec55 100644 --- a/examples/list.c +++ b/examples/list.c @@ -8,7 +8,7 @@ int main() { int k;
const int n = 2000000;
- clist_fx list = clist_ini;
+ clist_fx list = clist_INIT;
crand_rng64_t eng = crand_rng64_init(1234);
crand_uniform_f64_t dist = crand_uniform_f64_init(100.0f, n);
int m = 0;
@@ -50,5 +50,5 @@ int main() { c_foreach (i, clist_fx, it, clist_fx_end(&list))
printf(" %g", *i.get);
puts("");
- clist_fx_destroy(&list);
+ clist_fx_del(&list);
}
\ No newline at end of file diff --git a/examples/mapmap.c b/examples/mapmap.c index 57bcf384..38e88712 100644 --- a/examples/mapmap.c +++ b/examples/mapmap.c @@ -4,11 +4,11 @@ #include <stc/cstr.h>
using_cmap_str();
-using_cmap_strkey(cfg, cmap_str, cmap_str_destroy);
+using_cmap_strkey(cfg, cmap_str, cmap_str_del);
int main(void) {
- cmap_cfg config = cmap_ini;
- cmap_str init = cmap_ini;
+ cmap_cfg config = cmap_INIT;
+ cmap_str init = cmap_INIT;
cmap_str_put(&cmap_cfg_emplace(&config, "user", init).first->second, "name", "Joe");
cmap_str_put(&cmap_cfg_emplace(&config, "user", init).first->second, "groups", "proj1,proj3");
cmap_str_put(&cmap_cfg_emplace(&config, "group", init).first->second, "proj1", "Energy");
@@ -22,5 +22,5 @@ int main(void) { c_foreach (j, cmap_str, i.get->second)
printf("%s: %s - %s (%u)\n", i.get->first.str, j.get->first.str, j.get->second.str, i.get->second.bucket_count);
- cmap_cfg_destroy(&config);
+ cmap_cfg_del(&config);
}
\ No newline at end of file diff --git a/examples/phonebook.c b/examples/phonebook.c index 25d6ddb0..90d2fe22 100644 --- a/examples/phonebook.c +++ b/examples/phonebook.c @@ -36,7 +36,7 @@ void print_phone_book(cmap_str phone_book) int main(int argc, char **argv)
{
bool erased;
- cmap_str phone_book = cmap_ini;
+ cmap_str phone_book = cmap_INIT;
c_push_items(&phone_book, cmap_str, {
{"Lilia Friedman", "(892) 670-4739"},
{"Tariq Beltran", "(489) 600-7575"},
@@ -67,6 +67,6 @@ int main(int argc, char **argv) printf("\nPhone book after update phone of Zak Byers:\n");
print_phone_book(phone_book);
- cmap_str_destroy(&phone_book);
+ cmap_str_del(&phone_book);
puts("done");
}
\ No newline at end of file diff --git a/examples/prime.c b/examples/prime.c index d5b0b186..e49d2f20 100644 --- a/examples/prime.c +++ b/examples/prime.c @@ -33,5 +33,5 @@ int main(void) for (uint32_t i = 2; i <= 1000; ++i)
if (cbitset_test(primes, i)) printf("%u ", i);
puts("");
- cbitset_destroy(&primes);
+ cbitset_del(&primes);
}
\ No newline at end of file diff --git a/examples/priority.c b/examples/priority.c index 12e4be25..722d3164 100644 --- a/examples/priority.c +++ b/examples/priority.c @@ -31,5 +31,5 @@ int main() { printf("%zd ", *cpqueue_i_top(&heap));
cpqueue_i_pop(&heap);
}
- cpqueue_i_destroy(&heap);
+ cpqueue_i_del(&heap);
}
diff --git a/examples/queue.c b/examples/queue.c index e1eaf5d4..fc1c2704 100644 --- a/examples/queue.c +++ b/examples/queue.c @@ -16,7 +16,7 @@ int main() { // Push ten million random numbers onto the queue.
for (int i=0; i<n; ++i)
cqueue_i_push(&queue, crand_uniform_i32(&rng, &dist));
-
+
// Push or pop on the queue ten million times
printf("%d\n", n);
for (int i=n; i>0; --i) {
@@ -27,5 +27,5 @@ int main() { --n, cqueue_i_pop(&queue);
}
printf("%d, %zu\n", n, cqueue_i_size(queue));
- cqueue_i_destroy(&queue);
+ cqueue_i_del(&queue);
}
diff --git a/examples/random.c b/examples/random.c index b81f1826..df10acdc 100644 --- a/examples/random.c +++ b/examples/random.c @@ -58,10 +58,10 @@ int main() if (n >= 0 && n < R) ++hist[n];
}
- cstr_t bar = cstr_ini;
+ cstr_t bar = cstr_INIT;
for (int i=0; i < R; ++i) {
cstr_take(&bar, cstr_with_size(hist[i] * 25ull * R / N2, '*'));
printf("%2d %s\n", i, bar.str);
}
- cstr_destroy(&bar);
+ cstr_del(&bar);
}
\ No newline at end of file diff --git a/examples/replace.c b/examples/replace.c index c68a8940..c4929864 100644 --- a/examples/replace.c +++ b/examples/replace.c @@ -29,5 +29,5 @@ int main () cstr_replace(&s, 22, 1, "!!!"); // "this is a short phrase!!!" (5)
printf("(5) %s\n", s.str);
- c_dtor(cstr, &s, &m); // destroy
+ c_del_(cstr, &s, &m); // destroy
}
diff --git a/examples/words.c b/examples/words.c index e22a2a9b..c5b513bf 100644 --- a/examples/words.c +++ b/examples/words.c @@ -11,7 +11,7 @@ using_cmap_strkey(si, int); int main1() { - clist_str lwords = clist_ini; + clist_str lwords = clist_INIT; c_push_items(&lwords, clist_str, { "this", "sentence", "is", "not", "a", "sentence", "this", "sentence", "is", "a", "hoax" @@ -21,13 +21,13 @@ int main1() printf("%s\n", w.get->str); puts(""); - cvec_str words = cvec_ini; + cvec_str words = cvec_INIT; c_push_items(&words, cvec_str, { "this", "sentence", "is", "not", "a", "sentence", "this", "sentence", "is", "a", "hoax" }); - cmap_si word_map = cmap_ini; + cmap_si word_map = cmap_INIT; c_foreach (w, cvec_str, words) cmap_si_emplace(&word_map, w.get->str, 0).first->second += 1; @@ -37,8 +37,8 @@ int main1() pair.get->first.str); } - cmap_si_destroy(&word_map); - cvec_str_destroy(&words); + cmap_si_del(&word_map); + cvec_str_del(&words); return 0; } |
