diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/advanced.c | 2 | ||||
| -rw-r--r-- | examples/complex.c | 2 | ||||
| -rw-r--r-- | examples/csmap_v1.h | 10 | ||||
| -rw-r--r-- | examples/demos.c | 2 | ||||
| -rw-r--r-- | examples/phonebook.c | 2 | ||||
| -rw-r--r-- | examples/stc_astar.c | 2 |
6 files changed, 11 insertions, 9 deletions
diff --git a/examples/advanced.c b/examples/advanced.c index 753bba1e..f99d8671 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -54,7 +54,7 @@ int main() VikingRaw lookup = {"Einar", "Norway"}; - cmap_vk_value_t *e = cmap_vk_find(&vikings, lookup); + cmap_vk_value_t *e = cmap_vk_find(&vikings, lookup).ref; e->second += 3; // add 3 hp points to Einar cmap_vk_emplace(&vikings, lookup, 0).first->second += 5; // add 5 more to Einar diff --git a/examples/complex.c b/examples/complex.c index cbf07af2..d7ea016e 100644 --- a/examples/complex.c +++ b/examples/complex.c @@ -30,7 +30,7 @@ int main() { cmap_s_put(&myMap, strKey, listMap);
// Access the data entry
- carray2f arr_b = *clist_a_back(&cmap_l_find(&cmap_s_find(&myMap, strKey)->second, tableKey)->second);
+ carray2f arr_b = *clist_a_back(&cmap_l_find(&cmap_s_find(&myMap, strKey).ref->second, tableKey).ref->second);
printf("value (%d, %d) is: %f\n", y, x, *carray2f_at(&arr_b, y, x));
cmap_s_del(&myMap); // free up everything!
diff --git a/examples/csmap_v1.h b/examples/csmap_v1.h index 34917c5d..bc7a978d 100644 --- a/examples/csmap_v1.h +++ b/examples/csmap_v1.h @@ -142,7 +142,7 @@ int main(void) { typedef struct { \
C##_##X##_value_t *ref; \
int _top; \
- C##_##X##_node_t *_tn, *_st[50]; \
+ C##_##X##_node_t *_tn, *_st[48]; \
} C##_##X##_iter_t
@@ -206,14 +206,16 @@ int main(void) { STC_API C##_##X##_value_t* \
C##_##X##_find_it(const C##_##X* self, RawKey rkey, C##_##X##_iter_t* out); \
\
- STC_INLINE C##_##X##_value_t* \
+ STC_INLINE C##_##X##_iter_t \
C##_##X##_find(const C##_##X* self, RawKey rkey) { \
C##_##X##_iter_t it; \
- return C##_##X##_find_it(self, rkey, &it); \
+ C##_##X##_find_it(self, rkey, &it); \
+ return it; \
} \
STC_INLINE bool \
C##_##X##_contains(const C##_##X* self, RawKey rkey) { \
- return C##_##X##_find(self, rkey) != NULL; \
+ C##_##X##_iter_t it; \
+ return C##_##X##_find_it(self, rkey, &it) != NULL; \
} \
\
STC_API C##_##X##_result_t \
diff --git a/examples/demos.c b/examples/demos.c index aa1fa28b..46715b74 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -162,7 +162,7 @@ void mapdemo3() cmap_str_put(&table, "Map", "test");
cmap_str_put(&table, "Make", "my");
cmap_str_put(&table, "Sunny", "day");
- cmap_str_value_t *e = cmap_str_find(&table, "Make");
+ cmap_str_value_t *e = cmap_str_find(&table, "Make").ref;
c_foreach (i, cmap_str, table)
printf("entry: %s: %s\n", i.ref->first.str, i.ref->second.str);
printf("size %zu: remove: Make: %s\n", cmap_str_size(table), e->second.str);
diff --git a/examples/phonebook.c b/examples/phonebook.c index 1bedcce9..0f781334 100644 --- a/examples/phonebook.c +++ b/examples/phonebook.c @@ -52,7 +52,7 @@ int main(int argc, char **argv) printf("\nPhone book after adding Zak Byers:\n");
print_phone_book(phone_book);
- if (cmap_str_find(&phone_book, "Tariq Beltran") != NULL)
+ if (cmap_str_find(&phone_book, "Tariq Beltran").ref != NULL)
printf("\nTariq Beltran is in phone book\n");
erased = cmap_str_erase(&phone_book, "Tariq Beltran");
diff --git a/examples/stc_astar.c b/examples/stc_astar.c index 6421693a..91d475e9 100644 --- a/examples/stc_astar.c +++ b/examples/stc_astar.c @@ -103,7 +103,7 @@ astar(cstr maze, int width) int new_cost = *csmap_mc_at(&cost_so_far, current);
if (maze.str[mpoint_index(&next)] != '#')
{
- csmap_mc_value_t* cost = csmap_mc_find(&cost_so_far, next);
+ csmap_mc_value_t* cost = csmap_mc_find(&cost_so_far, next).ref;
if (!cost || new_cost < cost->second)
{
csmap_mc_put(&cost_so_far, next, new_cost); // update (put)
|
