diff options
| author | Tyge Løvset <[email protected]> | 2020-09-14 14:19:41 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-09-14 14:19:41 +0200 |
| commit | 0b7b008208c19bffc803b0b222af94223ac58551 (patch) | |
| tree | 4c032b4a2102114a26cc17052a087eea2aa42bc4 /examples | |
| parent | 131c47066cba5a8b59d5889415761d0300068bdc (diff) | |
| download | STC-modified-0b7b008208c19bffc803b0b222af94223ac58551.tar.gz STC-modified-0b7b008208c19bffc803b0b222af94223ac58551.zip | |
Renamed result_t type members to first, second (from item, inserted) for conformance with std::pair
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/advanced.c | 2 | ||||
| -rw-r--r-- | examples/benchmark.c | 2 | ||||
| -rw-r--r-- | examples/birthday.c | 4 | ||||
| -rw-r--r-- | examples/ex_gaussian.c | 2 | ||||
| -rw-r--r-- | examples/geek1.c | 12 | ||||
| -rw-r--r-- | examples/geek3.c | 8 | ||||
| -rw-r--r-- | examples/geek4.c | 4 | ||||
| -rw-r--r-- | examples/geek7.c | 2 | ||||
| -rw-r--r-- | examples/inits.c | 8 | ||||
| -rw-r--r-- | examples/mapmap.c | 14 | ||||
| -rw-r--r-- | examples/words.c | 2 |
11 files changed, 30 insertions, 30 deletions
diff --git a/examples/advanced.c b/examples/advanced.c index d3c1ca21..fe46f5da 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -71,7 +71,7 @@ int main() VikingVw einar = {"Einar", "Norway"}; cmap_vk_entry_t *e = cmap_vk_find(&vikings, einar); e->value += 5; // update - cmap_vk_emplace(&vikings, einar, 0).item->value += 5; // again + cmap_vk_emplace(&vikings, einar, 0).first->value += 5; // again c_foreach (k, cmap_vk, vikings) { printf("%s of %s has %d hp\n", k.item->key.name.str, k.item->key.country.str, k.item->value); diff --git a/examples/benchmark.c b/examples/benchmark.c index 99e06fee..3824e02f 100644 --- a/examples/benchmark.c +++ b/examples/benchmark.c @@ -36,7 +36,7 @@ crand_rng64_t rng; #define CMAP_SETUP(tt, Key, Value) cmap_##tt map = cmap_ini \
; cmap_##tt##_set_load_factors(&map, max_load_factor, 0.0)
-#define CMAP_PUT(tt, key, val) cmap_##tt##_put(&map, key, val).item->value
+#define CMAP_PUT(tt, key, val) cmap_##tt##_put(&map, key, val).first->value
#define CMAP_EMPLACE(tt, key, val) cmap_##tt##_emplace(&map, key, val)
#define CMAP_ERASE(tt, key) cmap_##tt##_erase(&map, key)
#define CMAP_FIND(tt, key) (cmap_##tt##_find(map, key) != NULL)
diff --git a/examples/birthday.c b/examples/birthday.c index 8b6abd77..59a8aee5 100644 --- a/examples/birthday.c +++ b/examples/birthday.c @@ -21,7 +21,7 @@ void repeats(void) clock_t now = clock();
for (size_t i = 0; i < N; ++i) {
uint64_t k = crand_i64(&rng) & mask;
- int v = ++cmap_ic_emplace(&m, k, 0).item->value;
+ int v = ++cmap_ic_emplace(&m, k, 0).first->value;
if (v > 1) printf("%zu: %llx - %d\n", i, k, v);
}
float diff = (float) (clock() - now) / CLOCKS_PER_SEC;
@@ -40,7 +40,7 @@ void distribution(void) clock_t now = clock();
crand_uniform_i32_t dist = crand_uniform_i32_init(0, M);
for (size_t i = 0; i < N; ++i) {
- ++cmap_x_emplace(&map, crand_uniform_i32(&rng, &dist), 0).item->value;
+ ++cmap_x_emplace(&map, crand_uniform_i32(&rng, &dist), 0).first->value;
}
float diff = (float) (clock() - now) / CLOCKS_PER_SEC;
diff --git a/examples/ex_gaussian.c b/examples/ex_gaussian.c index 8751ffa0..66abb889 100644 --- a/examples/ex_gaussian.c +++ b/examples/ex_gaussian.c @@ -32,7 +32,7 @@ int main() cmap_i mhist = cmap_ini;
for (size_t i = 0; i < N; ++i) {
int index = (int) round( crand_normal_f64(&rng, &dist) );
- cmap_i_emplace(&mhist, index, 0).item->value += 1;
+ cmap_i_emplace(&mhist, index, 0).first->value += 1;
}
// Transfer map to vec and sort it by map keys.
diff --git a/examples/geek1.c b/examples/geek1.c index 194b92da..983539b8 100644 --- a/examples/geek1.c +++ b/examples/geek1.c @@ -21,7 +21,7 @@ int findMaximumPairs(int a[], int n, int k) // Hash-table
cmap_ii hash = cmap_ini;
for (int i = 0; i < n; i++) {
- cmap_ii_emplace(&hash, a[i] % k, 0).item->value++;
+ cmap_ii_emplace(&hash, a[i] % k, 0).first->value++;
}
int count = 0;
@@ -35,11 +35,11 @@ int findMaximumPairs(int a[], int n, int k) count += it.item->value / 2;
cmap_ii_put(&hash, it.item->key, it.item->key & 1);
} else {
- int first = it.item->key;
- int second = k - it.item->key;
+ int one = it.item->key;
+ int two = k - it.item->key;
- cmap_ii_entry_t *hf = cmap_ii_find(&hash, first),
- *hs = cmap_ii_emplace(&hash, second, 0).item;
+ cmap_ii_entry_t *hf = cmap_ii_find(&hash, one),
+ *hs = cmap_ii_emplace(&hash, two, 0).first;
// Check for minimal occurrence
if (hf->value < hs->value) {
// Take the minimal
@@ -59,7 +59,7 @@ int findMaximumPairs(int a[], int n, int k) }
else {
// Check if numbers are same
- if (first == second) {
+ if (one == two) {
// If same then number of pairs will be half
count += it.item->value / 2;
diff --git a/examples/geek3.c b/examples/geek3.c index be3c8c10..9c959f0e 100644 --- a/examples/geek3.c +++ b/examples/geek3.c @@ -15,10 +15,10 @@ int main () // ...
cmap_si_put(&mymap, "Mars", 3396);
- cmap_si_emplace(&mymap, "Saturn", 0).item->value += 272;
- cmap_si_put(&mymap, "Jupiter", cmap_si_emplace(&mymap, "Saturn", 0).item->value + 9638);
- cmap_si_emplace(&mymap, "Sun", 0).item->value += 1000;
- cmap_si_emplace(&mymap, "Sun", 0).item->value += 1000;
+ cmap_si_emplace(&mymap, "Saturn", 0).first->value += 272;
+ cmap_si_put(&mymap, "Jupiter", cmap_si_emplace(&mymap, "Saturn", 0).first->value + 9638);
+ cmap_si_emplace(&mymap, "Sun", 0).first->value += 1000;
+ cmap_si_emplace(&mymap, "Sun", 0).first->value += 1000;
c_foreach (x, cmap_si, mymap) {
printf("%s: %d\n", x.item->key.str, x.item->value);
diff --git a/examples/geek4.c b/examples/geek4.c index 9f4df539..ec62efbc 100644 --- a/examples/geek4.c +++ b/examples/geek4.c @@ -106,13 +106,13 @@ int commonWords(cvec_str S) // make it false
for (int k = 0; k < cvec_size(ans); k++) {
if (ans.data[k].value != false
- && cmap_sb_emplace(&has, ans.data[k].key.str, false).item->value == false) {
+ && cmap_sb_emplace(&has, ans.data[k].key.str, false).first->value == false) {
ans.data[k].value = false;
}
// This line is used to consider only distinct words
else if (ans.data[k].value != false
- && cmap_sb_emplace(&has, ans.data[k].key.str, false).item->value == true) {
+ && cmap_sb_emplace(&has, ans.data[k].key.str, false).first->value == true) {
cmap_sb_put(&has, ans.data[k].key.str, false);
}
}
diff --git a/examples/geek7.c b/examples/geek7.c index 379dac9f..eb6b61cb 100644 --- a/examples/geek7.c +++ b/examples/geek7.c @@ -41,7 +41,7 @@ void findElementsAfterDel(int arr[], int m, int del[], for (int i = 0; i < n; ++i) {
// Increment the count of del[i]
- cmap_ii_emplace(&mp, del[i], 0).item->value++;
+ cmap_ii_emplace(&mp, del[i], 0).first->value++;
}
cpqueue_i heap = cpqueue_i_init();
diff --git a/examples/inits.c b/examples/inits.c index 5a0ae04b..7134c3ff 100644 --- a/examples/inits.c +++ b/examples/inits.c @@ -71,10 +71,10 @@ int main(void) { {"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;
- cmap_cnt_emplace(&countries, "Finland", 0).item->value += 20;
+ cmap_cnt_emplace(&countries, "Greenland", 0).first->value += 20;
+ cmap_cnt_emplace(&countries, "Sweden", 0).first->value += 20;
+ cmap_cnt_emplace(&countries, "Norway", 0).first->value += 20;
+ cmap_cnt_emplace(&countries, "Finland", 0).first->value += 20;
c_foreach (i, cmap_cnt, countries)
printf("%s: %d\n", i.item->key.str, i.item->value);
diff --git a/examples/mapmap.c b/examples/mapmap.c index f717a4bc..f3df9609 100644 --- a/examples/mapmap.c +++ b/examples/mapmap.c @@ -9,14 +9,14 @@ declare_cmap_strkey(cfg, cmap_str, cmap_str_destroy); int main(void) {
cmap_cfg config = cmap_ini;
cmap_str init = cmap_ini;
- cmap_str_put(&cmap_cfg_emplace(&config, "user", init).item->value, "name", "Joe");
- cmap_str_put(&cmap_cfg_emplace(&config, "user", init).item->value, "groups", "proj1,proj3");
- cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj1", "Energy");
- cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj2", "Windy");
- cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj3", "Oil");
- cmap_str_put(&cmap_cfg_emplace(&config, "admin", init).item->value, "employees", "2302");
+ cmap_str_put(&cmap_cfg_emplace(&config, "user", init).first->value, "name", "Joe");
+ cmap_str_put(&cmap_cfg_emplace(&config, "user", init).first->value, "groups", "proj1,proj3");
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).first->value, "proj1", "Energy");
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).first->value, "proj2", "Windy");
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).first->value, "proj3", "Oil");
+ cmap_str_put(&cmap_cfg_emplace(&config, "admin", init).first->value, "employees", "2302");
- cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj2", "Wind"); // Update
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).first->value, "proj2", "Wind"); // Update
c_foreach (i, cmap_cfg, config)
c_foreach (j, cmap_str, i.item->value)
diff --git a/examples/words.c b/examples/words.c index 09dd43dc..5fc80c62 100644 --- a/examples/words.c +++ b/examples/words.c @@ -29,7 +29,7 @@ int main1() cmap_si word_map = cmap_ini; c_foreach (w, cvec_str, words) - cmap_si_emplace(&word_map, w.item->str, 0).item->value += 1; + cmap_si_emplace(&word_map, w.item->str, 0).first->value += 1; c_foreach (pair, cmap_si, word_map) { printf("%d occurrences of word '%s'\n", |
