diff options
Diffstat (limited to 'examples/csmap_find.c')
| -rw-r--r-- | examples/csmap_find.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/csmap_find.c b/examples/csmap_find.c index 1b3320c9..eca14c52 100644 --- a/examples/csmap_find.c +++ b/examples/csmap_find.c @@ -33,9 +33,9 @@ using_print_collection(cvec_istr) void findit(csmap_istr c, csmap_istr_key_t val) { printf("Trying find() on value %d\n", val); - csmap_istr_value_t* result = csmap_istr_get(&c, val); // easier with get than find. - if (result) { - printf("Element found: "); print_elem(csmap_istr_value_toraw(result)); puts(""); + csmap_istr_iter_t result = csmap_istr_find(&c, val); // prefer contains() or get() + if (result.ref != csmap_istr_end(&c).ref) { + printf("Element found: "); print_elem(csmap_istr_value_toraw(result.ref)); puts(""); } else { puts("Element not found."); } @@ -61,7 +61,8 @@ int main() puts("Inserting the following vector data into m1:"); print_collection_cvec_istr(v); - c_foreach (i, cvec_istr, v) csmap_istr_emplace(&m1, i.ref->first, i.ref->second); + c_foreach (i, cvec_istr, cvec_istr_begin(&v), cvec_istr_end(&v)) + csmap_istr_emplace(&m1, i.ref->first, i.ref->second); puts("The modified map m1 is (key, value):"); print_collection_csmap_istr(m1); |
