diff options
| author | Tyge Løvset <[email protected]> | 2020-09-16 09:11:39 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-09-16 09:11:39 +0200 |
| commit | d3d68271e1c4ff0f56d06730f79349197f46850c (patch) | |
| tree | 16e76392bf9a9027d6582d5bce639ed1bcda86e0 | |
| parent | 47b096d57f2d716db40a9ec6e724c2a76038778d (diff) | |
| download | STC-modified-d3d68271e1c4ff0f56d06730f79349197f46850c.tar.gz STC-modified-d3d68271e1c4ff0f56d06730f79349197f46850c.zip | |
Renamed two public macros.
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | examples/README.md | 4 | ||||
| -rw-r--r-- | examples/advanced.c | 2 | ||||
| -rw-r--r-- | examples/inits.c | 12 | ||||
| -rw-r--r-- | examples/list.c | 2 | ||||
| -rw-r--r-- | examples/phonebook.c | 2 | ||||
| -rw-r--r-- | examples/priority.c | 2 | ||||
| -rw-r--r-- | examples/words.c | 4 | ||||
| -rw-r--r-- | stc/cdefs.h | 2 | ||||
| -rw-r--r-- | stc/cmap.h | 2 |
10 files changed, 18 insertions, 18 deletions
@@ -299,8 +299,8 @@ int main() { clist_fx_clear(&list);
- // generic c_push() function, works on most containers:
- c_push(&list, clist_fx, {10, 20, 30, 40, 50});
+ // generic c_push_items() function, works on most containers:
+ c_push_items(&list, clist_fx, {10, 20, 30, 40, 50});
c_foreach (i, clist_fx, list)
printf("%f ", i.get->value);
diff --git a/examples/README.md b/examples/README.md index 98e366df..d12cc522 100644 --- a/examples/README.md +++ b/examples/README.md @@ -57,11 +57,11 @@ c_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash, viking_destroy, 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.
-Finally, main which also demos the generic c_push() of multiple elements:
+Finally, main which also demos the generic c_push_items() of multiple elements:
```
int main() {
cmap_vk vikings = cmap_ini;
- c_push(&vikings, cmap_vk, {
+ c_push_items(&vikings, cmap_vk, {
{ {"Einar", "Norway"}, 20 },
{ {"Olaf", "Denmark"}, 24 },
{ {"Harald", "Iceland"}, 12 },
diff --git a/examples/advanced.c b/examples/advanced.c index c48c25a2..0570ce55 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -62,7 +62,7 @@ c_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash, int main() { cmap_vk vikings = cmap_ini; - c_push(&vikings, cmap_vk, { + c_push_items(&vikings, cmap_vk, { {{"Einar", "Norway"}, 20}, {{"Olaf", "Denmark"}, 24}, {{"Harald", "Iceland"}, 12}, diff --git a/examples/inits.c b/examples/inits.c index 1bd6e5f4..6540290a 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, {4.0f, 2.0f, 5.0f, 3.0f, 1.0f});
+ 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);
puts("");
@@ -33,7 +33,7 @@ int main(void) { // CVEC PRIORITY QUEUE
cpqueue_f_build(&floats); // reorganise vec
- c_push(&floats, cpqueue_f, {40.0f, 20.0f, 50.0f, 30.0f, 10.0f});
+ c_push_items(&floats, cpqueue_f, {40.0f, 20.0f, 50.0f, 30.0f, 10.0f});
// sorted:
while (cvec_size(floats) > 0) {
@@ -47,7 +47,7 @@ int main(void) { int year = 2020;
cmap_id idnames = cmap_ini;
- c_push(&idnames, cmap_id, {
+ c_push_items(&idnames, cmap_id, {
{100, cstr("Hello")},
{110, cstr("World")},
{120, cstr_from("Howdy, -%d-", year)},
@@ -61,7 +61,7 @@ int main(void) { // CMAP CNT
cmap_cnt countries = cmap_ini;
- c_push(&countries, cmap_cnt, {
+ c_push_items(&countries, cmap_cnt, {
{"Norway", 100},
{"Denmark", 50},
{"Iceland", 10},
@@ -84,7 +84,7 @@ int main(void) { // CVEC PAIR
cvec_ip pairs1 = cvec_ini;
- c_push(&pairs1, cvec_ip, {
+ c_push_items(&pairs1, cvec_ip, {
{5, 6},
{3, 4},
{1, 2},
@@ -100,7 +100,7 @@ int main(void) { // CLIST PAIR
clist_ip pairs2 = clist_ini;
- c_push(&pairs2, clist_ip, {
+ c_push_items(&pairs2, clist_ip, {
{5, 6},
{3, 4},
{1, 2},
diff --git a/examples/list.c b/examples/list.c index cea8c7f6..a0a3b456 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, {10, 20, 30, 40, 30, 50});
+ c_push_items(&list, clist_fx, {10, 20, 30, 40, 30, 50});
c_foreach (i, clist_fx, list) printf(" %g", i.get->value);
puts("");
diff --git a/examples/phonebook.c b/examples/phonebook.c index 9cc9245f..5395d774 100644 --- a/examples/phonebook.c +++ b/examples/phonebook.c @@ -37,7 +37,7 @@ int main(int argc, char **argv) {
bool erased;
cmap_str phone_book = cmap_ini;
- c_push(&phone_book, cmap_str, {
+ c_push_items(&phone_book, cmap_str, {
{"Lilia Friedman", "(892) 670-4739"},
{"Tariq Beltran", "(489) 600-7575"},
{"Laiba Juarez", "(303) 885-5692"},
diff --git a/examples/priority.c b/examples/priority.c index 6e39e63b..1a8eff78 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, {-231, -32, -873, -4, -343});
+ c_push_items(&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 d720fa0e..fe738d0d 100644 --- a/examples/words.c +++ b/examples/words.c @@ -12,7 +12,7 @@ c_cmap_strkey(si, int); int main1() { clist_str lwords = clist_ini; - c_push(&lwords, clist_str, { + c_push_items(&lwords, clist_str, { "this", "sentence", "is", "not", "a", "sentence", "this", "sentence", "is", "a", "hoax" }); @@ -22,7 +22,7 @@ int main1() puts(""); cvec_str words = cvec_ini; - c_push(&words, cvec_str, { + c_push_items(&words, cvec_str, { "this", "sentence", "is", "not", "a", "sentence", "this", "sentence", "is", "a", "hoax" }); diff --git a/stc/cdefs.h b/stc/cdefs.h index df56987e..ef6fd62f 100644 --- a/stc/cdefs.h +++ b/stc/cdefs.h @@ -85,7 +85,7 @@ #define c_foreach_4(it, ctype, start, finish) \
for (ctype##_iter_t it = start, it##_end_ = finish; it.get != it##_end_.get; ctype##_next(&it))
-#define c_push(self, ctype, ...) do { \
+#define c_push_items(self, ctype, ...) do { \
const ctype##_input_t __arr[] = __VA_ARGS__; \
ctype##_push_n(self, __arr, sizeof(__arr)/sizeof(__arr[0])); \
} while (0)
@@ -65,7 +65,7 @@ int main(void) { ctype##_result_t __r = ctype##_insert_key_(self, key); \
if (__r.second) __r.first->second = val; \
} while (0)
-#define c_insert(self, ctype, ...) do { \
+#define c_insert_items(self, ctype, ...) do { \
const ctype##_input_t __arr[] = __VA_ARGS__; \
for (size_t i=0;i<sizeof(__arr)/sizeof(__arr[0]); ++i) ctype##_insert(self, __arr[i]); \
} while (0)
|
