summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-14 13:17:39 +0200
committerTyge Løvset <[email protected]>2020-09-14 13:17:39 +0200
commit131c47066cba5a8b59d5889415761d0300068bdc (patch)
tree50af1ab74d6cd2616d9b797aaef71f1aea4de8cf /examples
parentab21f83c4af4f2b628ce36ad03f5c78fbb11a06a (diff)
downloadSTC-modified-131c47066cba5a8b59d5889415761d0300068bdc.tar.gz
STC-modified-131c47066cba5a8b59d5889415761d0300068bdc.zip
Got rid of c_items() macro.
Diffstat (limited to 'examples')
-rw-r--r--examples/README.md4
-rw-r--r--examples/advanced.c4
-rw-r--r--examples/geek2.c4
-rw-r--r--examples/inits.c20
-rw-r--r--examples/list.c2
-rw-r--r--examples/phonebook.c4
-rw-r--r--examples/priority.c2
-rw-r--r--examples/words.c8
8 files changed, 24 insertions, 24 deletions
diff --git a/examples/README.md b/examples/README.md
index 0cdefd55..26eb4bb1 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -61,11 +61,11 @@ Finally, main which also demos the generic c_push() of multiple elements:
```
int main() {
cmap_vk vikings = cmap_ini;
- c_push(&vikings, cmap_vk, c_items(
+ c_push(&vikings, cmap_vk, {
{ {"Einar", "Norway"}, 20 },
{ {"Olaf", "Denmark"}, 24 },
{ {"Harald", "Iceland"}, 12 },
- ));
+ });
VikingVw look = {"Einar", "Norway"};
cmap_vk_entry_t *e = cmap_vk_find(&vikings, look);
e->value += 5; // update
diff --git a/examples/advanced.c b/examples/advanced.c
index 0aa1600e..d3c1ca21 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -62,11 +62,11 @@ declare_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
int main()
{
cmap_vk vikings = cmap_ini;
- c_push(&vikings, cmap_vk, c_items(
+ c_push(&vikings, cmap_vk, {
{{"Einar", "Norway"}, 20},
{{"Olaf", "Denmark"}, 24},
{{"Harald", "Iceland"}, 12},
- ));
+ });
VikingVw einar = {"Einar", "Norway"};
cmap_vk_entry_t *e = cmap_vk_find(&vikings, einar);
diff --git a/examples/geek2.c b/examples/geek2.c
index c76d262f..a02ede25 100644
--- a/examples/geek2.c
+++ b/examples/geek2.c
@@ -20,12 +20,12 @@ int main()
puts("");
// Review some books.
- c_push(&book_reviews, cmap_str, c_items(
+ c_push(&book_reviews, cmap_str, {
{"Adventures of Huckleberry Finn", "My favorite book."},
{"Grimms' Fairy Tales", "Masterpiece."},
{"Pride and Prejudice", "Very enjoyable."},
{"The Adventures of Sherlock Holmes", "Eye lyked it alot."},
- ));
+ });
/*
cmap_str_emplace(&book_reviews,
"Adventures of Huckleberry Finn",
diff --git a/examples/inits.c b/examples/inits.c
index ebb2e0e1..5a0ae04b 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -25,7 +25,7 @@ int main(void) {
// CVEC FLOAT / PRIORITY QUEUE
cvec_f floats = cvec_ini;
- c_push(&floats, cvec_f, c_items(4.0f, 2.0f, 5.0f, 3.0f, 1.0f));
+ c_push(&floats, cvec_f, {4.0f, 2.0f, 5.0f, 3.0f, 1.0f});
c_foreach (i, cvec_f, floats) printf("%.1f ", *i.item);
puts("");
@@ -33,7 +33,7 @@ int main(void) {
// CVEC PRIORITY QUEUE
cpqueue_f_build(&floats); // reorganise vec
- c_push(&floats, cpqueue_f, c_items(40.0f, 20.0f, 50.0f, 30.0f, 10.0f));
+ c_push(&floats, cpqueue_f, {40.0f, 20.0f, 50.0f, 30.0f, 10.0f});
// sorted:
while (cvec_size(floats) > 0) {
@@ -47,11 +47,11 @@ int main(void) {
int year = 2020;
cmap_id idnames = cmap_ini;
- c_push(&idnames, cmap_id, c_items(
+ c_push(&idnames, cmap_id, {
{100, cstr_make("Hello")},
{110, cstr_make("World")},
{120, cstr_from("Howdy, -%d-", year)},
- ));
+ });
c_foreach (i, cmap_id, idnames)
printf("%d: %s\n", i.item->key, i.item->value.str);
@@ -61,7 +61,7 @@ int main(void) {
// CMAP CNT
cmap_cnt countries = cmap_ini;
- c_push(&countries, cmap_cnt, c_items(
+ c_push(&countries, cmap_cnt, {
{"Norway", 100},
{"Denmark", 50},
{"Iceland", 10},
@@ -70,7 +70,7 @@ int main(void) {
{"Germany", 10},
{"Spain", 10},
{"France", 10},
- ));
+ });
cmap_cnt_emplace(&countries, "Greenland", 0).item->value += 20;
cmap_cnt_emplace(&countries, "Sweden", 0).item->value += 20;
cmap_cnt_emplace(&countries, "Norway", 0).item->value += 20;
@@ -84,12 +84,12 @@ int main(void) {
// CVEC PAIR
cvec_ip pairs1 = cvec_ini;
- c_push(&pairs1, cvec_ip, c_items(
+ c_push(&pairs1, cvec_ip, {
{5, 6},
{3, 4},
{1, 2},
{7, 8},
- ));
+ });
cvec_ip_sort(&pairs1);
c_foreach (i, cvec_ip, pairs1)
@@ -100,12 +100,12 @@ int main(void) {
// CLIST PAIR
clist_ip pairs2 = clist_ini;
- c_push(&pairs2, clist_ip, c_items(
+ c_push(&pairs2, clist_ip, {
{5, 6},
{3, 4},
{1, 2},
{7, 8},
- ));
+ });
clist_ip_sort(&pairs2);
c_foreach (i, clist_ip, pairs2)
diff --git a/examples/list.c b/examples/list.c
index dd8bba2f..d140d103 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -23,7 +23,7 @@ int main() {
puts("");
clist_fx_clear(&list);
- c_push(&list, clist_fx, c_items(10, 20, 30, 40, 30, 50));
+ c_push(&list, clist_fx, {10, 20, 30, 40, 30, 50});
c_foreach (i, clist_fx, list) printf(" %g", i.item->value);
puts("");
diff --git a/examples/phonebook.c b/examples/phonebook.c
index 74105f25..983f4e74 100644
--- a/examples/phonebook.c
+++ b/examples/phonebook.c
@@ -37,12 +37,12 @@ int main(int argc, char **argv)
{
bool erased;
cmap_str phone_book = cmap_ini;
- c_push(&phone_book, cmap_str, c_items(
+ c_push(&phone_book, cmap_str, {
{"Lilia Friedman", "(892) 670-4739"},
{"Tariq Beltran", "(489) 600-7575"},
{"Laiba Juarez", "(303) 885-5692"},
{"Elliott Mooney", "(945) 616-4482"},
- ));
+ });
printf("Phone book:\n");
print_phone_book(phone_book);
diff --git a/examples/priority.c b/examples/priority.c
index e857761c..8bd2abce 100644
--- a/examples/priority.c
+++ b/examples/priority.c
@@ -20,7 +20,7 @@ int main() {
cpqueue_i_push(&heap, crand_uniform_i64(&pcg, &dist));
// push some negative numbers too.
- c_push(&heap, cpqueue_i, c_items(-231, -32, -873, -4, -343));
+ c_push(&heap, cpqueue_i, {-231, -32, -873, -4, -343});
for (int i=0; i<N; ++i)
cpqueue_i_push(&heap, crand_uniform_i64(&pcg, &dist));
diff --git a/examples/words.c b/examples/words.c
index 9e0fc0cc..09dd43dc 100644
--- a/examples/words.c
+++ b/examples/words.c
@@ -12,20 +12,20 @@ declare_cmap_strkey(si, int);
int main1()
{
clist_str lwords = clist_ini;
- c_push(&lwords, clist_str, c_items(
+ c_push(&lwords, clist_str, {
"this", "sentence", "is", "not", "a", "sentence",
"this", "sentence", "is", "a", "hoax"
- ));
+ });
clist_str_push_back(&lwords, cstr_from("%f", 123897.0 / 23.0));
c_foreach (w, clist_str, lwords)
printf("%s\n", w.item->value.str);
puts("");
cvec_str words = cvec_ini;
- c_push(&words, cvec_str, c_items(
+ c_push(&words, cvec_str, {
"this", "sentence", "is", "not", "a", "sentence",
"this", "sentence", "is", "a", "hoax"
- ));
+ });
cmap_si word_map = cmap_ini;
c_foreach (w, cvec_str, words)