diff options
| author | Tyge Løvset <[email protected]> | 2020-12-17 07:55:59 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-12-17 07:55:59 +0100 |
| commit | bc2981ee8fa3cba0be0d0efb1e2a2072c98ca5a0 (patch) | |
| tree | 2e848e43a77cf4507645d7b89231c9a726b3ec05 | |
| parent | 214a2aa75d164d285661719131f54c71fa2f8e37 (diff) | |
| download | STC-modified-bc2981ee8fa3cba0be0d0efb1e2a2072c98ca5a0.tar.gz STC-modified-bc2981ee8fa3cba0be0d0efb1e2a2072c98ca5a0.zip | |
API change: Reverted back to original name used for .val in iterators to .ref
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | docs/carray_api.md | 8 | ||||
| -rw-r--r-- | docs/clist_api.md | 22 | ||||
| -rw-r--r-- | docs/cmap_api.md | 10 | ||||
| -rw-r--r-- | docs/copt_api.md | 2 | ||||
| -rw-r--r-- | docs/cptr_api.md | 6 | ||||
| -rw-r--r-- | docs/cqueue_api.md | 2 | ||||
| -rw-r--r-- | docs/crand_api.md | 6 | ||||
| -rw-r--r-- | docs/cset_api.md | 12 | ||||
| -rw-r--r-- | docs/cstr_api.md | 2 | ||||
| -rw-r--r-- | docs/cvec_api.md | 20 | ||||
| -rw-r--r-- | examples/README.md | 2 | ||||
| -rw-r--r-- | examples/advanced.c | 2 | ||||
| -rw-r--r-- | examples/birthday.c | 4 | ||||
| -rw-r--r-- | examples/demos.c | 24 | ||||
| -rw-r--r-- | examples/ex_gaussian.c | 6 | ||||
| -rw-r--r-- | examples/inits.c | 10 | ||||
| -rw-r--r-- | examples/list.c | 12 | ||||
| -rw-r--r-- | examples/mapmap.c | 4 | ||||
| -rw-r--r-- | examples/phonebook.c | 2 | ||||
| -rw-r--r-- | examples/ptr.c | 6 | ||||
| -rw-r--r-- | examples/share_ptr.c | 8 | ||||
| -rw-r--r-- | examples/share_ptr2.c | 2 | ||||
| -rw-r--r-- | examples/stack.c | 2 | ||||
| -rw-r--r-- | examples/words.c | 6 | ||||
| -rw-r--r-- | stc/carray.h | 6 | ||||
| -rw-r--r-- | stc/cbitset.h | 6 | ||||
| -rw-r--r-- | stc/ccommon.h | 4 | ||||
| -rw-r--r-- | stc/clist.h | 32 | ||||
| -rw-r--r-- | stc/cmap.h | 16 | ||||
| -rw-r--r-- | stc/cptr.h | 2 | ||||
| -rw-r--r-- | stc/cstr.h | 6 | ||||
| -rw-r--r-- | stc/cvec.h | 20 |
33 files changed, 138 insertions, 138 deletions
@@ -33,7 +33,7 @@ int main(void) { cvec_i_push_back(&vec, 1);
cvec_i_push_back(&vec, 2);
c_foreach (i, cvec_i, vec)
- printf(" %d", *i.val);
+ printf(" %d", *i.ref);
cvec_i_del(&vec);
}
```
@@ -59,7 +59,7 @@ int main(void) { cvec_u_push_back(&vec, (User) {cstr_from("admin"), 0}); // cstr_from() allocates string memory
cvec_u_push_back(&vec, (User) {cstr_from("usera"), 1});
c_foreach (i, cvec_u, vec)
- printf("%s: %d\n", i.val->name.str, i.val->id);
+ printf("%s: %d\n", i.ref->name.str, i.ref->id);
cvec_u_del(&vec); // free everything
}
```
diff --git a/docs/carray_api.md b/docs/carray_api.md index 9d80ad13..24841448 100644 --- a/docs/carray_api.md +++ b/docs/carray_api.md @@ -19,7 +19,7 @@ be replaced by `my` in all of the following documentation. The `#` character sho |:---------------------|:------------------------------|:--------------------------| | `carray#X` | `struct { ... }` | The carray type | | `carray#X_value_t` | `Value` | The value type | -| `carray#X_iter_t` | `struct { Value *val; }` | Iterator type | +| `carray#X_iter_t` | `struct { Value *ref; }` | Iterator type | ## Constants and macros @@ -46,9 +46,9 @@ All cset definitions and prototypes may be included in your C source file by inc ### Constructors ```c -carray1X carray1X_init(size_t xdim, Value val); -carray2X carray2X_init(size_t ydim, size_t xdim, Value val); -carray3X carray3X_init(size_t zdim, size_t ydim, size_t xdim, Value val); +carray1X carray1X_init(size_t xdim, Value ref); +carray2X carray2X_init(size_t ydim, size_t xdim, Value ref); +carray3X carray3X_init(size_t zdim, size_t ydim, size_t xdim, Value ref); carray1X carray1X_from(Value* array, size_t xdim); carray2X carray2X_from(Value* array, size_t ydim, size_t xdim); carray3X carray3X_from(Value* array, size_t zdim, size_t ydim, size_t xdim); diff --git a/docs/clist_api.md b/docs/clist_api.md index 8bb48b37..f3f17270 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -29,7 +29,7 @@ using_clist(str, cstr_t, cstr_del, cstr_compare_raw, const char*, cstr_to_raw, c | `clist_X_value_t` | `Value` | The clist element type | | `clist_X_input_t` | `clist_X_value_t` | clist input type | | `clist_X_rawvalue_t` | `RawValue` | clist raw value type | -| `clist_X_iter_t` | `struct { clist_value_t *val; ... }`| clist iterator | +| `clist_X_iter_t` | `struct { clist_value_t *ref; ... }`| clist iterator | ## Constants and macros @@ -61,15 +61,15 @@ clist_X_value_t* clist_X_front(clist_X* self); clist_X_value_t* clist_X_back(clist_X* self); void clist_X_push_n(clist_X *self, const clist_X_input_t in[], size_t size); -void clist_X_emplace_back(clist_X* self, RawValue val); +void clist_X_emplace_back(clist_X* self, RawValue ref); void clist_X_push_back(clist_X* self, Value value); -void clist_X_emplace_front(clist_X* self, RawValue val); +void clist_X_emplace_front(clist_X* self, RawValue ref); void clist_X_push_front(clist_X* self, Value value); void clist_X_pop_front(clist_X* self); -clist_X_iter_t clist_X_emplace_after(clist_X* self, clist_X_iter_t pos, RawValue val); -clist_X_iter_t clist_X_insert_after(clist_X* self, clist_X_iter_t pos, Value val); +clist_X_iter_t clist_X_emplace_after(clist_X* self, clist_X_iter_t pos, RawValue ref); +clist_X_iter_t clist_X_insert_after(clist_X* self, clist_X_iter_t pos, Value ref); clist_X_iter_t clist_X_erase_after(clist_X* self, clist_X_iter_t pos); clist_X_iter_t clist_X_erase_range_after(clist_X* self, clist_X_iter_t pos, clist_X_iter_t finish); @@ -78,11 +78,11 @@ void clist_X_splice_front(clist_X* self, clist_X* other); void clist_X_splice_back(clist_X* self, clist_X* other); void clist_X_splice_after(clist_X* self, clist_X_iter_t pos, clist_X* other); -clist_X_iter_t clist_X_find(const clist_X* self, RawValue val); +clist_X_iter_t clist_X_find(const clist_X* self, RawValue ref); clist_X_iter_t clist_X_find_before(const clist_X* self, - clist_X_iter_t first, clist_X_iter_t finish, RawValue val); + clist_X_iter_t first, clist_X_iter_t finish, RawValue ref); -size_t clist_X_remove(clist_X* self, RawValue val); +size_t clist_X_remove(clist_X* self, RawValue ref); void clist_X_sort(clist_X* self); @@ -93,7 +93,7 @@ clist_X_iter_t clist_X_end(const clist_X* self); void clist_X_next(clist_X_iter_t* it); clist_X_value_t* clist_X_itval(clist_X_iter_t it); -Value clist_X_value_from_raw(RawValue val); +Value clist_X_value_from_raw(RawValue ref); ``` ## Example @@ -116,13 +116,13 @@ int main() { printf("initial: "); c_foreach (i, clist_d, list) - printf(" %g", *i.val); + printf(" %g", *i.ref); clist_d_sort(&list); // mergesort O(n*log n) printf("\nsorted: "); c_foreach (i, clist_d, list) - printf(" %g", *i.val); + printf(" %g", *i.ref); clist_d_del(&list); } diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 197d4b92..b1fd7a3a 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -51,7 +51,7 @@ using_cmap(str, cstr_t, cstr_t, cstr_del, cstr_equals_raw, cstr_hash_raw, | `cmap_X_value_t` | `struct { Key first; Mapped second; }` | The value type | | `cmap_X_input_t` | `struct { RawKey first; RawMapped second; }` | RawKey + RawVal type | | `cmap_X_result_t` | `struct { cmap_X_value_t first; bool second; }` | Result of insert/put/emplace | -| `cmap_X_iter_t` | `struct { cmap_X_value_t *val; ... }` | Iterator type | +| `cmap_X_iter_t` | `struct { cmap_X_value_t *ref; ... }` | Iterator type | ## Constants and macros @@ -61,7 +61,7 @@ using_cmap(str, cstr_t, cstr_t, cstr_del, cstr_equals_raw, cstr_hash_raw, | `cmap_empty(map)` | Test for empty map | | `cmap_size(map)` | Get map size | | `cmap_capacity(map)` | Get map capacity | -| `c_try_emplace(self, ctype, key, val)` | Emplace if key exist | +| `c_try_emplace(self, ctype, key, ref)` | Emplace if key exist | ## Header file @@ -98,7 +98,7 @@ cmap_X_result_t cmap_X_put_mapped(cmap_X* self, RawKey rkey, Mapped mapped); cmap_X_mapped_t* cmap_X_at(const cmap_X* self, RawKey rkey); size_t cmap_X_erase(cmap_X* self, RawKey rkey); -void cmap_X_erase_entry(cmap_X* self, cmap_X_value_t* val); +void cmap_X_erase_entry(cmap_X* self, cmap_X_value_t* ref); cmap_X_iter_t cmap_X_erase_at(cmap_X* self, cmap_X_iter_t pos); cmap_X_value_t* cmap_X_find(const cmap_X* self, RawKey rkey); @@ -134,7 +134,7 @@ int main() // Iterate and print keys and values of unordered map c_foreach (n, cmap_str, u) { - printf("Key:[%s] Value:[%s]\n", n.val->first.str, n.val->second.str); + printf("Key:[%s] Value:[%s]\n", n.ref->first.str, n.ref->second.str); } // Add two new entries to the unordered map @@ -179,7 +179,7 @@ int main() cmap_id_put(&idnames, 80, cstr_from("White")); c_foreach (i, cmap_id, idnames) - printf("%d: %s\n", i.val->first, i.val->second.str); + printf("%d: %s\n", i.ref->first, i.ref->second.str); puts(""); cmap_id_del(&idnames); diff --git a/docs/copt_api.md b/docs/copt_api.md index 819ac7b3..3c0d1719 100644 --- a/docs/copt_api.md +++ b/docs/copt_api.md @@ -22,7 +22,7 @@ typedef struct { typedef struct { const char *name; int has_arg; - int val; + int ref; } copt_long_t; ``` diff --git a/docs/cptr_api.md b/docs/cptr_api.md index 6273833e..560db243 100644 --- a/docs/cptr_api.md +++ b/docs/cptr_api.md @@ -51,7 +51,7 @@ int cptr_X_compare(cptr_X* x, cptr_X* y); ``` ```c csptr_X csptr_X_from(csptr_X_value_t* ptr); -csptr_X csptr_X_make(csptr_X_value_t val); +csptr_X csptr_X_make(csptr_X_value_t ref); csptr_X csptr_X_share(csptr_X ptr); void csptr_X_reset(csptr_X* self, csptr_X_value_t* p); void csptr_X_del(csptr_X* self); @@ -101,14 +101,14 @@ int main() { puts("cvec of cptr<Person>:"); cvec_pp_sort(&pvec); c_foreach (i, cvec_pp, pvec) - printf(" %s %s\n", (*i.val)->name.str, (*i.val)->last.str); + printf(" %s %s\n", (*i.ref)->name.str, (*i.ref)->last.str); cvec_ps svec = cvec_inits; for (int i=0;i<6; i+=2) cvec_ps_push_back(&svec, csptr_ps_from(Person_make(c_new(Person), names[i], names[i+1]))); puts("cvec of csptr<Person>:"); cvec_ps_sort(&svec); c_foreach (i, cvec_ps, svec) - printf(" %s %s\n", i.val->get->name.str, i.val->get->last.str); + printf(" %s %s\n", i.ref->get->name.str, i.ref->get->last.str); csptr_ps x = csptr_ps_share(svec.data[1]); diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md index b5cbfe29..4645cbeb 100644 --- a/docs/cqueue_api.md +++ b/docs/cqueue_api.md @@ -72,7 +72,7 @@ int main() { cqueue_i_pop(&queue); c_foreach (i, cqueue_i, queue) - printf(" %d", *i.val); + printf(" %d", *i.ref); cqueue_i_del(&queue); } diff --git a/docs/crand_api.md b/docs/crand_api.md index df452a49..3eb0bf43 100644 --- a/docs/crand_api.md +++ b/docs/crand_api.md @@ -95,16 +95,16 @@ int main() // Transfer map to vec and sort it by map entry keys. cvec_e vhist = cvec_e_init(); c_foreach (i, cmap_i, mhist) - cvec_e_push_back(&vhist, *i.val); + cvec_e_push_back(&vhist, *i.ref); cvec_e_sort(&vhist); // Print the gaussian bar chart cstr_t bar = cstr_init(); c_foreach (i, cvec_e, vhist) { - size_t n = (size_t) (i.val->second * StdDev * Scale * 2.5 / N); + size_t n = (size_t) (i.ref->second * StdDev * Scale * 2.5 / N); if (n > 0) { cstr_resize(&bar, n, '*'); - printf("%4d %s\n", i.val->first, bar.str); + printf("%4d %s\n", i.ref->first, bar.str); } } diff --git a/docs/cset_api.md b/docs/cset_api.md index 3e63f383..223dd1cf 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -32,7 +32,7 @@ be replaced by `my` in all of the following documentation. | `cset_X_value_t` | `Key` | The value type |
| `cset_X_result_t` | `struct { Key first; bool second; }` | Result of insert/emplace |
| `cset_X_input_t` | `cset_X_rawkey_t` | The input type (rawkey) |
-| `cset_X_iter_t` | `struct { cset_X_value_t *val; ... }` | Iterator type |
+| `cset_X_iter_t` | `struct { cset_X_value_t *ref; ... }` | Iterator type |
## Constants and macros
@@ -42,7 +42,7 @@ be replaced by `my` in all of the following documentation. | `cset_empty(set)` | Test for empty set |
| `cset_size(set)` | Get set size |
| `cset_capacity(set)` | Get set capacity |
-| `c_try_emplace(self, ctype, key, val)` | Emplace if key exist |
+| `c_try_emplace(self, ctype, key, ref)` | Emplace if key exist |
## Header file
@@ -110,13 +110,13 @@ int main () cset_str_emplace(&fourth, "flour");
cset_str fifth = cset_inits;
- c_foreach (x, cset_str, second) cset_str_emplace(&fifth, x.val->str);
- c_foreach (x, cset_str, third) cset_str_emplace(&fifth, x.val->str);
- c_foreach (x, cset_str, fourth) cset_str_emplace(&fifth, x.val->str);
+ c_foreach (x, cset_str, second) cset_str_emplace(&fifth, x.ref->str);
+ c_foreach (x, cset_str, third) cset_str_emplace(&fifth, x.ref->str);
+ c_foreach (x, cset_str, fourth) cset_str_emplace(&fifth, x.ref->str);
c_del(cset_str, &first, &second, &third, &fourth);
printf("fifth contains:\n\n");
- c_foreach (x, cset_str, fifth) printf("%s\n", x.val->str);
+ c_foreach (x, cset_str, fifth) printf("%s\n", x.ref->str);
cset_str_del(&fifth);
return 0;
diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 97fc4032..7a86ecc8 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -8,7 +8,7 @@ This describes the API of string type **cstr_t**. |:------------------|:---------------------------------|:---------------------------| | `cstr_t` | `struct { const char *str; }` | The string type | | `cstr_value_t` | `char` | The string element type | -| `cstr_iter_t` | `struct { cstr_value_t *val; }` | cstr_t iterator | +| `cstr_iter_t` | `struct { cstr_value_t *ref; }` | cstr_t iterator | ## Constants and macros diff --git a/docs/cvec_api.md b/docs/cvec_api.md index d33a4d42..628d5acd 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -30,7 +30,7 @@ using_cvec(str, cstr_t, cstr_del, cstr_compare_raw, const char*, cstr_to_raw, cs | `cvec_X_value_t` | `Value` | The cvec value type | | `cvec_X_input_t` | `cvec_X_value_t` | The input type | | `cvec_X_rawvalue_t` | `RawValue` | The raw value type | -| `cvec_X_iter_t` | `struct { cvec_X_value_t* val; }` | The iterator type | +| `cvec_X_iter_t` | `struct { cvec_X_value_t* ref; }` | The iterator type | ## Constants and macros @@ -73,12 +73,12 @@ cvec_X_value_t* cvec_X_front(cvec_X* self); cvec_X_value_t* cvec_X_back(cvec_X* self); void cvec_X_push_n(cvec_X *self, const cvec_X_input_t arr[], size_t size); -void cvec_X_emplace_back(cvec_X* self, RawValue val); +void cvec_X_emplace_back(cvec_X* self, RawValue ref); void cvec_X_push_back(cvec_X* self, Value value); void cvec_X_pop_back(cvec_X* self); -cvec_X_iter_t cvec_X_emplace(cvec_X* self, cvec_X_iter_t pos, RawValue val); -cvec_X_iter_t cvec_X_emplace_at(cvec_X* self, size_t idx, RawValue val); +cvec_X_iter_t cvec_X_emplace(cvec_X* self, cvec_X_iter_t pos, RawValue ref); +cvec_X_iter_t cvec_X_emplace_at(cvec_X* self, size_t idx, RawValue ref); cvec_X_iter_t cvec_X_insert(cvec_X* self, cvec_X_iter_t pos, Value value); cvec_X_iter_t cvec_X_insert_at(cvec_X* self, size_t idx, Value value); cvec_X_iter_t cvec_X_insert_range(cvec_X* self, cvec_X_iter_t pos, @@ -91,9 +91,9 @@ cvec_X_iter_t cvec_X_erase_n(cvec_X* self, size_t idx, size_t n); cvec_X_iter_t cvec_X_erase_range(cvec_X* self, cvec_X_iter_t first, cvec_X_iter_t finish); cvec_X_iter_t cvec_X_erase_range_p(cvec_X* self, cvec_X_value_t* pfirst, cvec_X_value_t* pfinish); -cvec_X_iter_t cvec_X_find(const cvec_X* self, RawValue val); +cvec_X_iter_t cvec_X_find(const cvec_X* self, RawValue ref); cvec_X_iter_t cvec_X_find_in_range(const cvec_X* self, - cvec_X_iter_t first, cvec_X_iter_t finish, RawValue val); + cvec_X_iter_t first, cvec_X_iter_t finish, RawValue ref); void cvec_X_sort(cvec_X* self); void cvec_X_sort_with(cvec_X* self, size_t ifirst, size_t ifinish, @@ -105,7 +105,7 @@ void cvec_X_next(cvec_X_iter_t* it); cvec_X_value_t* cvec_X_itval(cvec_X_iter_t it); size_t cvec_X_index(const cvec_X vec, cvec_X_iter_t it); -Value cvec_X_value_from_raw(RawValue val); +Value cvec_X_value_from_raw(RawValue ref); ``` ## Examples @@ -126,7 +126,7 @@ int main() printf("initial: "); c_foreach (n, cvec_i, vec) { - printf(" %d", *n.val); + printf(" %d", *n.ref); } // Sort the vector @@ -134,7 +134,7 @@ int main() printf("\nsorted: "); c_foreach (n, cvec_i, vec) { - printf(" %d", *n.val); + printf(" %d", *n.ref); } cvec_i_del(&vec); @@ -166,7 +166,7 @@ int main() { printf("%s\n", names.data[1].str); // Access the second element c_foreach (i, cvec_str, names) - printf("item: %s\n", i.val->str); + printf("item: %s\n", i.ref->str); cvec_str_del(&names); } ``` diff --git a/examples/README.md b/examples/README.md index 114f6aac..bcb6b163 100644 --- a/examples/README.md +++ b/examples/README.md @@ -72,7 +72,7 @@ int main() { cmap_vk_emplace(&vikings, look, 0)->second += 5; // update again
c_foreach (k, cmap_vk, vikings) {
- printf("%s of %s has %d hp\n", k.val->first.name.str, k.val->first.country.str, k.val->second);
+ printf("%s of %s has %d hp\n", k.ref->first.name.str, k.ref->first.country.str, k.ref->second);
}
cmap_vk_del(&vikings);
}
diff --git a/examples/advanced.c b/examples/advanced.c index 280d5ce4..931efb57 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -73,7 +73,7 @@ int main() cmap_vk_emplace(&vikings, einar, 0).first->second += 5; // again c_foreach (k, cmap_vk, vikings) { - printf("%s of %s has %d HP\n", k.val->first.name.str, k.val->first.country.str, k.val->second); + printf("%s of %s has %d HP\n", k.ref->first.name.str, k.ref->first.country.str, k.ref->second); } cmap_vk_del(&vikings); } diff --git a/examples/birthday.c b/examples/birthday.c index a13fa8c9..7ed30bf1 100644 --- a/examples/birthday.c +++ b/examples/birthday.c @@ -45,11 +45,11 @@ void distribution(void) float diff = (float) (clock() - now) / CLOCKS_PER_SEC;
uint64_t sum = 0;
- c_foreach (i, cmap_x, map) sum += i.val->second;
+ c_foreach (i, cmap_x, map) sum += i.ref->second;
sum /= map.size;
c_foreach (i, cmap_x, map)
- printf("%u: %zu - %zu\n", i.val->first, i.val->second, sum);
+ printf("%u: %zu - %zu\n", i.ref->first, i.ref->second, sum);
printf("%.02f\n", diff);
}
diff --git a/examples/demos.c b/examples/demos.c index f5df2c00..cf32ca9d 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -72,7 +72,7 @@ void vectordemo2() cvec_str_sort(&names); // Sort the array
c_foreach (i, cvec_str, names)
- printf("sorted: %s\n", i.val->str);
+ printf("sorted: %s\n", i.ref->str);
cvec_str_del(&names);
}
@@ -87,19 +87,19 @@ void listdemo1() for (int i = 100; i < 110; ++i)
clist_ix_push_back(&nums2, i);
c_foreach (i, clist_ix, nums)
- printf("value: %d\n", *i.val);
+ printf("value: %d\n", *i.ref);
/* merge/append nums2 to nums */
clist_ix_splice_front(&nums, &nums2);
c_foreach (i, clist_ix, nums)
- printf("spliced: %d\n", *i.val);
+ printf("spliced: %d\n", *i.ref);
- *clist_ix_find(&nums, 100).val *= 10;
+ *clist_ix_find(&nums, 100).ref *= 10;
clist_ix_sort(&nums); // Sort the array
clist_ix_remove(&nums, 105);
clist_ix_pop_front(&nums);
clist_ix_push_front(&nums, -99);
c_foreach (i, clist_ix, nums)
- printf("sorted: %d\n", *i.val);
+ printf("sorted: %d\n", *i.ref);
clist_ix_del(&nums);
}
@@ -113,7 +113,7 @@ void setdemo1() cset_i_insert(&nums, 11);
c_foreach (i, cset_i, nums)
- printf("set: %d\n", *i.val);
+ printf("set: %d\n", *i.ref);
cset_i_del(&nums);
}
@@ -142,12 +142,12 @@ void mapdemo2() cmap_si_put(&nums, "Groovy", 200); // overwrite previous
// iterate the map:
- for (cmap_si_iter_t i = cmap_si_begin(&nums); i.val != cmap_si_end(&nums).val; cmap_si_next(&i))
- printf("long: %s: %d\n", i.val->first.str, i.val->second);
+ for (cmap_si_iter_t i = cmap_si_begin(&nums); i.ref != cmap_si_end(&nums).ref; cmap_si_next(&i))
+ printf("long: %s: %d\n", i.ref->first.str, i.ref->second);
// or rather use the short form:
c_foreach (i, cmap_si, nums)
- printf("short: %s: %d\n", i.val->first.str, i.val->second);
+ printf("short: %s: %d\n", i.ref->first.str, i.ref->second);
cmap_si_del(&nums);
}
@@ -164,13 +164,13 @@ void mapdemo3() cmap_str_put(&table, "Sunny", "day");
cmap_str_value_t *e = cmap_str_find(&table, "Make");
c_foreach (i, cmap_str, table)
- printf("entry: %s: %s\n", i.val->first.str, i.val->second.str);
+ printf("entry: %s: %s\n", i.ref->first.str, i.ref->second.str);
printf("size %zu: remove: Make: %s\n", cmap_size(table), e->second.str);
cmap_str_erase(&table, "Make");
printf("size %zu\n", cmap_size(table));
c_foreach (i, cmap_str, table)
- printf("entry: %s: %s\n", i.val->first.str, i.val->second.str);
+ printf("entry: %s: %s\n", i.ref->first.str, i.ref->second.str);
cmap_str_del(&table); // frees key and value cstrs, and hash table.
}
@@ -193,7 +193,7 @@ void arraydemo1() printf("%f\n", *carray3f_at(&a3, 5, 4, 3)); // lookup a3[5][4][3] (=10.2f)
c_foreach (i, carray3f, a3)
- *i.val = 1.0f;
+ *i.ref = 1.0f;
printf("%f\n", *carray3f_at(&a3, 29, 19, 9));
carray2f_del(&a2); // does nothing, since it is a sub-array.
diff --git a/examples/ex_gaussian.c b/examples/ex_gaussian.c index 0fed913f..5357a2f8 100644 --- a/examples/ex_gaussian.c +++ b/examples/ex_gaussian.c @@ -38,16 +38,16 @@ int main() // Transfer map to vec and sort it by map keys.
cvec_e vhist = cvec_e_init();
c_foreach (i, cmap_i, mhist)
- cvec_e_push_back(&vhist, *i.val);
+ cvec_e_push_back(&vhist, *i.ref);
cvec_e_sort(&vhist);
// Print the gaussian bar chart
cstr_t bar = cstr_init();
c_foreach (i, cvec_e, vhist) {
- size_t n = (size_t) (i.val->second * StdDev * Scale * 2.5 / N);
+ size_t n = (size_t) (i.ref->second * StdDev * Scale * 2.5 / N);
if (n > 0) {
cstr_resize(&bar, n, '*');
- printf("%4d %s\n", i.val->first, bar.str);
+ printf("%4d %s\n", i.ref->first, bar.str);
}
}
// Cleanup
diff --git a/examples/inits.c b/examples/inits.c index e358b466..4ce1421a 100644 --- a/examples/inits.c +++ b/examples/inits.c @@ -26,7 +26,7 @@ int main(void) cvec_f floats = cvec_inits;
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.val);
+ c_foreach (i, cvec_f, floats) printf("%.1f ", *i.ref);
puts("");
// CVEC PRIORITY QUEUE
@@ -53,7 +53,7 @@ int main(void) });
c_foreach (i, cmap_id, idnames)
- printf("%d: %s\n", i.val->first, i.val->second.str);
+ printf("%d: %s\n", i.ref->first, i.ref->second.str);
puts("");
cmap_id_del(&idnames);
@@ -76,7 +76,7 @@ int main(void) cmap_cnt_emplace(&countries, "Finland", 0).first->second += 20;
c_foreach (i, cmap_cnt, countries)
- printf("%s: %d\n", i.val->first.str, i.val->second);
+ printf("%s: %d\n", i.ref->first.str, i.ref->second);
puts("");
cmap_cnt_del(&countries);
@@ -92,7 +92,7 @@ int main(void) cvec_ip_sort(&pairs1);
c_foreach (i, cvec_ip, pairs1)
- printf("(%d %d) ", i.val->x, i.val->y);
+ printf("(%d %d) ", i.ref->x, i.ref->y);
puts("");
cvec_ip_del(&pairs1);
@@ -108,7 +108,7 @@ int main(void) clist_ip_sort(&pairs2);
c_foreach (i, clist_ip, pairs2)
- printf("(%d %d) ", i.val->x, i.val->y);
+ printf("(%d %d) ", i.ref->x, i.ref->y);
puts("");
clist_ip_del(&pairs2);
}
\ No newline at end of file diff --git a/examples/list.c b/examples/list.c index a838b3bd..d65da22b 100644 --- a/examples/list.c +++ b/examples/list.c @@ -17,24 +17,24 @@ int main() { double sum = 0.0;
printf("sumarize %d:\n", m);
c_foreach (i, clist_fx, list)
- sum += *i.val;
+ sum += *i.ref;
printf("sum %f\n\n", sum);
k = 0;
c_foreach (i, clist_fx, list)
- if (++k <= 10) printf("%8d: %10f\n", k, *i.val); else break;
+ if (++k <= 10) printf("%8d: %10f\n", k, *i.ref); else break;
puts("sort");
clist_fx_sort(&list); // mergesort O(n*log n)
puts("sorted");
k = 0;
c_foreach (i, clist_fx, list)
- if (++k <= 10) printf("%8d: %10f\n", k, *i.val); else break;
+ if (++k <= 10) printf("%8d: %10f\n", k, *i.ref); else break;
puts("");
clist_fx_clear(&list);
c_push_items(&list, clist_fx, {10, 20, 30, 40, 30, 50});
- c_foreach (i, clist_fx, list) printf(" %g", *i.val);
+ c_foreach (i, clist_fx, list) printf(" %g", *i.ref);
puts("");
int removed = clist_fx_remove(&list, 30);
@@ -44,11 +44,11 @@ int main() { clist_fx_iter_t it = clist_fx_before_begin(&list);
printf("Full: ");
c_foreach (i, clist_fx, list)
- printf(" %g", *i.val);
+ printf(" %g", *i.ref);
for (int i=0; i<4; ++i) clist_fx_next(&it);
printf("\nSubs: ");
c_foreach (i, clist_fx, it, clist_fx_end(&list))
- printf(" %g", *i.val);
+ printf(" %g", *i.ref);
puts("");
clist_fx_del(&list);
}
\ No newline at end of file diff --git a/examples/mapmap.c b/examples/mapmap.c index 2ee46e8f..1128387d 100644 --- a/examples/mapmap.c +++ b/examples/mapmap.c @@ -19,8 +19,8 @@ int main(void) { cmap_str_put(&cmap_cfg_emplace(&config, "group", init).first->second, "proj2", "Wind"); // Update
c_foreach (i, cmap_cfg, config)
- c_foreach (j, cmap_str, i.val->second)
- printf("%s: %s - %s (%u)\n", i.val->first.str, j.val->first.str, j.val->second.str, i.val->second.bucket_count);
+ c_foreach (j, cmap_str, i.ref->second)
+ printf("%s: %s - %s (%u)\n", i.ref->first.str, j.ref->first.str, j.ref->second.str, i.ref->second.bucket_count);
cmap_cfg_del(&config);
}
\ No newline at end of file diff --git a/examples/phonebook.c b/examples/phonebook.c index 9eaa2933..91d01072 100644 --- a/examples/phonebook.c +++ b/examples/phonebook.c @@ -30,7 +30,7 @@ using_cmap_str(); void print_phone_book(cmap_str phone_book)
{
c_foreach (i, cmap_str, phone_book)
- printf("%s\t- %s\n", i.val->first.str, i.val->second.str);
+ printf("%s\t- %s\n", i.ref->first.str, i.ref->second.str);
}
int main(int argc, char **argv)
diff --git a/examples/ptr.c b/examples/ptr.c index 6fbc74d6..b32fdb33 100644 --- a/examples/ptr.c +++ b/examples/ptr.c @@ -39,21 +39,21 @@ int main() { puts("cvec of Person:");
cvec_pe_sort(&vec);
c_foreach (i, cvec_pe, vec)
- printf(" %s %s\n", i.val->name.str, i.val->last.str);
+ printf(" %s %s\n", i.ref->name.str, i.ref->last.str);
cvec_pu uvec = cvec_inits;
for (int i=0;i<6; i+=2) cvec_pu_push_back(&uvec, Person_make(c_new(Person), names[i], names[i+1]));
puts("cvec of cptr<Person>:");
cvec_pu_sort(&uvec);
c_foreach (i, cvec_pu, uvec)
- printf(" %s %s\n", (*i.val)->name.str, (*i.val)->last.str);
+ printf(" %s %s\n", (*i.ref)->name.str, (*i.ref)->last.str);
cvec_ps svec = cvec_inits;
for (int i=0;i<6; i+=2) cvec_ps_push_back(&svec, csptr_ps_from(Person_make(c_new(Person), names[i], names[i+1])));
puts("cvec of csptr<Person>:");
cvec_ps_sort(&svec);
c_foreach (i, cvec_ps, svec)
- printf(" %s %s\n", (*i.val).get->name.str, (*i.val).get->last.str);
+ printf(" %s %s\n", (*i.ref).get->name.str, (*i.ref).get->last.str);
csptr_ps x = csptr_ps_share(svec.data[1]);
diff --git a/examples/share_ptr.c b/examples/share_ptr.c index d851fc58..2ec2470e 100644 --- a/examples/share_ptr.c +++ b/examples/share_ptr.c @@ -41,7 +41,7 @@ int main() { cvec_pe_push_back(&vec, csptr_pe_share(p)); // Don't forget to share!
}
c_foreach (i, clist_pe, queue)
- printf(" %s\n", i.val->get->name.str);
+ printf(" %s\n", i.ref->get->name.str);
puts("Sort and pop 3:");
clist_pe_sort(&queue);
@@ -53,16 +53,16 @@ int main() { puts("Sorted queue:");
c_foreach (i, clist_pe, queue)
- printf(" %s\n", i.val->get->name.str);
+ printf(" %s\n", i.ref->get->name.str);
puts("Sorted vec:");
c_foreach (i, cvec_pe, vec)
- printf(" %s\n", i.val->get->name.str);
+ printf(" %s\n", i.ref->get->name.str);
Person lost; Person_make(&lost, "Name 5", "Last 5");
csptr_pe ptmp = {&lost, NULL}; // share pointer without counter - OK.
clist_pe_iter_t lit = clist_pe_find(&queue, ptmp);
Person_del(&lost);
- if (lit.val) printf("Found: %s\n", lit.val->get->name.str);
+ if (lit.ref) printf("Found: %s\n", lit.ref->get->name.str);
printf("use %ld\n", *joe.use_count);
csptr_pe_del(&joe);
diff --git a/examples/share_ptr2.c b/examples/share_ptr2.c index abb58705..65240969 100644 --- a/examples/share_ptr2.c +++ b/examples/share_ptr2.c @@ -25,6 +25,6 @@ int main() { cstr_from_fmt("Last %d", (i * 9) % 10))));
}
c_foreach (i, cmap_ps, map)
- printf(" %d: %s\n", i.val->first, i.val->second.get->name.str);
+ printf(" %d: %s\n", i.ref->first, i.ref->second.get->name.str);
cmap_ps_del(&map);
}
\ No newline at end of file diff --git a/examples/stack.c b/examples/stack.c index f65b9243..3bcf05dd 100644 --- a/examples/stack.c +++ b/examples/stack.c @@ -21,7 +21,7 @@ int main() { cstack_i_pop(&stack);
c_foreach (i, cstack_i, stack)
- printf(" %d", *i.val);
+ printf(" %d", *i.ref);
puts("");
printf("top: %d\n", *cstack_i_top(&stack));
}
\ No newline at end of file diff --git a/examples/words.c b/examples/words.c index 7017cebb..7e80c452 100644 --- a/examples/words.c +++ b/examples/words.c @@ -18,7 +18,7 @@ int main1() }); clist_str_push_back(&lwords, cstr_from_fmt("%f", 123897.0 / 23.0)); c_foreach (w, clist_str, lwords) - printf("%s\n", w.val->str); + printf("%s\n", w.ref->str); puts(""); cvec_str words = cvec_inits; @@ -29,10 +29,10 @@ int main1() cmap_si word_map = cmap_inits; c_foreach (w, cvec_str, words) - cmap_si_emplace(&word_map, w.val->str, 0).first->second += 1; + cmap_si_emplace(&word_map, w.ref->str, 0).first->second += 1; c_foreach (i, cmap_si, word_map) { - printf("%d occurrences of word '%s'\n", i.val->second, i.val->first.str); + printf("%d occurrences of word '%s'\n", i.ref->second, i.ref->first.str); } cmap_si_del(&word_map); diff --git a/stc/carray.h b/stc/carray.h index 44df27a8..25c61ec7 100644 --- a/stc/carray.h +++ b/stc/carray.h @@ -68,7 +68,7 @@ _carray3_size(const size_t* zdim) {return zdim[0] * zdim[-1] * zdim[-2];} #define using_carray_common(D, X, Value, valueDestroy) \
- typedef struct { Value *val; } carray##D##X##_iter_t; \
+ typedef struct { Value *ref; } carray##D##X##_iter_t; \
\
STC_INLINE carray##D##X##_iter_t \
carray##D##X##_begin(carray##D##X* a) { \
@@ -79,13 +79,13 @@ _carray3_size(const size_t* zdim) {return zdim[0] * zdim[-1] * zdim[-2];} carray##D##X##_iter_t it = {a->data + carray##D##_size(*a)}; return it; \
} \
STC_INLINE void \
- carray##D##X##_next(carray##D##X##_iter_t* it) {++it->val;} \
+ carray##D##X##_next(carray##D##X##_iter_t* it) {++it->ref;} \
\
STC_INLINE void \
carray##D##X##_del(carray##D##X* self) { \
if (self->_xdim & _carray_OWN) { \
c_foreach_3 (i, carray##D##X, *self) \
- valueDestroy(i.val); \
+ valueDestroy(i.ref); \
c_free(self->data); \
} \
}
diff --git a/stc/cbitset.h b/stc/cbitset.h index 2e1887a2..69c9fe7e 100644 --- a/stc/cbitset.h +++ b/stc/cbitset.h @@ -149,7 +149,7 @@ STC_INLINE cbitset_t cbitset_not(cbitset_t s1) { typedef struct {
cbitset_t *_bs;
- size_t val;
+ size_t ref;
} cbitset_iter_t;
STC_INLINE cbitset_iter_t
@@ -161,10 +161,10 @@ cbitset_end(cbitset_t* self) { cbitset_iter_t it = {self, self->size}; return it;
}
STC_INLINE void
-cbitset_next(cbitset_iter_t* it) {++it->val;}
+cbitset_next(cbitset_iter_t* it) {++it->ref;}
STC_INLINE bool cbitset_itval(cbitset_iter_t it) {
- return cbitset_test(*it._bs, it.val);
+ return cbitset_test(*it._bs, it.ref);
}
#if defined(__GNUC__) || defined(__clang__)
diff --git a/stc/ccommon.h b/stc/ccommon.h index 3cda038d..0df794df 100644 --- a/stc/ccommon.h +++ b/stc/ccommon.h @@ -89,9 +89,9 @@ #define c_foreach(...) c_MACRO_OVERLOAD(c_foreach, __VA_ARGS__)
#define c_foreach_3(it, ctype, cnt) \
- for (ctype##_iter_t it = ctype##_begin(&cnt), it##_end_ = ctype##_end(&cnt); it.val != it##_end_.val; ctype##_next(&it))
+ for (ctype##_iter_t it = ctype##_begin(&cnt), it##_end_ = ctype##_end(&cnt); it.ref != it##_end_.ref; ctype##_next(&it))
#define c_foreach_4(it, ctype, start, finish) \
- for (ctype##_iter_t it = start, it##_end_ = finish; it.val != it##_end_.val; ctype##_next(&it))
+ for (ctype##_iter_t it = start, it##_end_ = finish; it.ref != it##_end_.ref; ctype##_next(&it))
#define c_forrange(...) c_MACRO_OVERLOAD(c_forrange, __VA_ARGS__)
#define c_forrange_1(stop) for (size_t _c_i=0, _c_end_=stop; _c_i < _c_end_; ++_c_i)
diff --git a/stc/clist.h b/stc/clist.h index 838edf07..af31bf96 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -42,13 +42,13 @@ clist_ix_push_back(&list, crand_next(&rng) >> 32);
n = 0;
c_foreach (i, clist_ix, list)
- if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.val->value);
+ if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.ref->value);
// Sort them...
clist_ix_sort(&list); // mergesort O(n*log n)
n = 0;
puts("sorted");
c_foreach (i, clist_ix, list)
- if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.val->value);
+ if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.ref->value);
clist_ix_del(&list);
}
*/
@@ -81,7 +81,7 @@ \
typedef struct { \
clist_##X##_node_t* const* _last; \
- clist_##X##_value_t* val; \
+ clist_##X##_value_t* ref; \
int _state; \
} clist_##X##_iter_t
@@ -165,11 +165,11 @@ STC_API size_t _clist_size(const clist_void* self); } \
STC_INLINE void \
clist_##X##_next(clist_##X##_iter_t* it) { \
- clist_##X##_node_t* node = _clist_node(X, it->val); \
- it->val = ((it->_state += node == *it->_last) == 1) ? NULL : &node->next->value; \
+ clist_##X##_node_t* node = _clist_node(X, it->ref); \
+ it->ref = ((it->_state += node == *it->_last) == 1) ? NULL : &node->next->value; \
} \
STC_INLINE clist_##X##_value_t* \
- clist_##X##_itval(clist_##X##_iter_t it) {return it.val;} \
+ clist_##X##_itval(clist_##X##_iter_t it) {return it.ref;} \
\
STC_API clist_##X##_iter_t \
clist_##X##_insert_after(clist_##X* self, clist_##X##_iter_t pos, Value value); \
@@ -219,7 +219,7 @@ STC_API size_t _clist_size(const clist_void* self); clist_##X##_clone(clist_##X list) { \
clist_##X out = clist_inits; \
c_foreach_3 (i, clist_##X, list) \
- clist_##X##_emplace_back(&out, valueToRaw(i.val)); \
+ clist_##X##_emplace_back(&out, valueToRaw(i.ref)); \
return out; \
} \
STC_DEF void \
@@ -244,19 +244,19 @@ STC_API size_t _clist_size(const clist_void* self); \
STC_DEF clist_##X##_iter_t \
clist_##X##_insert_after(clist_##X* self, clist_##X##_iter_t pos, Value value) { \
- clist_##X##_node_t* node = pos.val ? _clist_node(X, pos.val) : NULL; \
+ clist_##X##_node_t* node = pos.ref ? _clist_node(X, pos.ref) : NULL; \
_c_clist_insert_after(self, X, node, value); \
if (!node || node == self->last && pos._state == 0) self->last = entry; \
- pos.val = &entry->value, pos._state = 0; return pos; \
+ pos.ref = &entry->value, pos._state = 0; return pos; \
} \
STC_DEF clist_##X##_iter_t \
clist_##X##_erase_after(clist_##X* self, clist_##X##_iter_t pos) { \
- _clist_##X##_erase_after(self, _clist_node(X, pos.val)); \
+ _clist_##X##_erase_after(self, _clist_node(X, pos.ref)); \
clist_##X##_next(&pos); return pos; \
} \
STC_DEF clist_##X##_iter_t \
clist_##X##_erase_range_after(clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish) { \
- clist_##X##_node_t* node = _clist_node(X, first.val), *done = finish.val ? _clist_node(X, finish.val) : NULL; \
+ clist_##X##_node_t* node = _clist_node(X, first.ref), *done = finish.ref ? _clist_node(X, finish.ref) : NULL; \
while (node && node->next != done) \
node = _clist_##X##_erase_after(self, node); \
clist_##X##_next(&first); return first; \
@@ -265,8 +265,8 @@ STC_API size_t _clist_size(const clist_void* self); STC_DEF clist_##X##_iter_t \
clist_##X##_find_before(const clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish, RawValue val) { \
clist_##X##_iter_t i = first; \
- for (clist_##X##_next(&i); i.val != finish.val; clist_##X##_next(&i)) { \
- RawValue r = valueToRaw(i.val); \
+ for (clist_##X##_next(&i); i.ref != finish.ref; clist_##X##_next(&i)) { \
+ RawValue r = valueToRaw(i.ref); \
if (valueCompareRaw(&r, &val) == 0) return first; \
first = i; \
} \
@@ -276,7 +276,7 @@ STC_API size_t _clist_size(const clist_void* self); STC_DEF clist_##X##_iter_t \
clist_##X##_find(const clist_##X* self, RawValue val) { \
clist_##X##_iter_t it = clist_##X##_find_before(self, clist_##X##_before_begin(self), clist_##X##_end(self), val); \
- if (it.val != clist_##X##_end(self).val) clist_##X##_next(&it); \
+ if (it.ref != clist_##X##_end(self).ref) clist_##X##_next(&it); \
return it; \
} \
STC_DEF clist_##X##_node_t* \
@@ -306,10 +306,10 @@ STC_API size_t _clist_size(const clist_void* self); \
STC_DEF void \
clist_##X##_splice_after(clist_##X* self, clist_##X##_iter_t pos, clist_##X* other) { \
- if (!pos.val) \
+ if (!pos.ref) \
self->last = other->last; \
else if (other->last) { \
- clist_##X##_node_t *node = _clist_node(X, pos.val), *next = node->next; \
+ clist_##X##_node_t *node = _clist_node(X, pos.ref), *next = node->next; \
node->next = other->last->next; \
other->last->next = next; \
if (node == self->last && pos._state == 0) self->last = other->last; \
@@ -34,7 +34,7 @@ int main(void) { cset_sx_insert(&s, 5);
cset_sx_insert(&s, 8);
c_foreach (i, cset_sx, s)
- printf("set %d\n", i.val->second);
+ printf("set %d\n", i.ref->second);
cset_sx_del(&s);
cmap_mx m = cmap_inits;
@@ -46,7 +46,7 @@ int main(void) { cmap_mx_put(&m, 5, 'd'); // update
cmap_mx_erase(&m, 8);
c_foreach (i, cmap_mx, m)
- printf("map %d: %c\n", i.val->first, i.val->second);
+ printf("map %d: %c\n", i.ref->first, i.ref->second);
cmap_mx_del(&m);
}
*/
@@ -195,7 +195,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; } ctype##_##X; \
\
typedef struct { \
- ctype##_##X##_value_t *val; \
+ ctype##_##X##_value_t *ref; \
uint8_t* _hx; \
} ctype##_##X##_iter_t; \
\
@@ -274,7 +274,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; STC_INLINE ctype##_##X##_iter_t \
ctype##_##X##_begin(ctype##_##X* self) { \
ctype##_##X##_iter_t it = {self->table, self->_hashx}; \
- if (it._hx) while (*it._hx == 0) ++it.val, ++it._hx; \
+ if (it._hx) while (*it._hx == 0) ++it.ref, ++it._hx; \
return it; \
} \
STC_INLINE ctype##_##X##_iter_t \
@@ -283,13 +283,13 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; } \
STC_INLINE void \
ctype##_##X##_next(ctype##_##X##_iter_t* it) { \
- while ((++it->val, *++it->_hx == 0)) ; \
+ while ((++it->ref, *++it->_hx == 0)) ; \
} \
\
CMAP_ONLY_##ctype( STC_INLINE ctype##_##X##_mapped_t* \
- ctype##_##X##_itval(ctype##_##X##_iter_t it) {return &it.val->second;} ) \
+ ctype##_##X##_itval(ctype##_##X##_iter_t it) {return &it.ref->second;} ) \
CSET_ONLY_##ctype( STC_INLINE ctype##_##X##_value_t* \
- ctype##_##X##_itval(ctype##_##X##_iter_t it) {return it.val;} ) \
+ ctype##_##X##_itval(ctype##_##X##_iter_t it) {return it.ref;} ) \
\
STC_API void \
ctype##_##X##_erase_entry(ctype##_##X* self, ctype##_##X##_value_t* val); \
@@ -301,7 +301,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; } \
STC_INLINE ctype##_##X##_iter_t \
ctype##_##X##_erase_at(ctype##_##X* self, ctype##_##X##_iter_t pos) { \
- ctype##_##X##_erase_entry(self, pos.val); \
+ ctype##_##X##_erase_entry(self, pos.ref); \
ctype##_##X##_next(&pos); return pos; \
} \
\
@@ -53,7 +53,7 @@ int main() { cvec_pe_push_back(&vec, Person_make(c_new(Person), "Jane", "Jacobs"));
c_foreach (i, cvec_pe, vec)
- printf("%s %s\n", (*i.val)->name.str, (*i.val)->last.str);
+ printf("%s %s\n", (*i.ref)->name.str, (*i.ref)->last.str);
cvec_pe_del(&vec);
}
*/
@@ -31,7 +31,7 @@ #include <ctype.h>
typedef struct cstr { char* str; } cstr_t;
-typedef struct { char *val; } cstr_iter_t;
+typedef struct { char *ref; } cstr_iter_t;
typedef char cstr_value_t;
#define cstr_size(s) ((const size_t *) (s).str)[-2]
@@ -130,8 +130,8 @@ STC_INLINE cstr_iter_t cstr_end(cstr_t* self) {
cstr_iter_t it = {self->str + cstr_size(*self)}; return it;
}
-STC_INLINE void cstr_next(cstr_iter_t* it) { ++it->val; }
-STC_INLINE char* cstr_itval(cstr_iter_t it) {return it.val;}
+STC_INLINE void cstr_next(cstr_iter_t* it) { ++it->ref; }
+STC_INLINE char* cstr_itval(cstr_iter_t it) {return it.ref;}
STC_INLINE cstr_t*
cstr_assign(cstr_t* self, const char* str) {
@@ -48,7 +48,7 @@ typedef Value cvec_##X##_value_t; \
typedef RawValue cvec_##X##_rawvalue_t; \
typedef cvec_##X##_rawvalue_t cvec_##X##_input_t; \
- typedef struct { cvec_##X##_value_t *val; } cvec_##X##_iter_t; \
+ typedef struct { cvec_##X##_value_t *ref; } cvec_##X##_iter_t; \
\
typedef struct { \
cvec_##X##_value_t* data; \
@@ -108,11 +108,11 @@ \
STC_INLINE cvec_##X##_iter_t \
cvec_##X##_insert_range(cvec_##X* self, cvec_##X##_iter_t pos, cvec_##X##_iter_t first, cvec_##X##_iter_t finish) { \
- return cvec_##X##_insert_range_p(self, pos.val, first.val, finish.val); \
+ return cvec_##X##_insert_range_p(self, pos.ref, first.ref, finish.ref); \
} \
STC_INLINE cvec_##X##_iter_t \
cvec_##X##_insert(cvec_##X* self, cvec_##X##_iter_t pos, Value value) { \
- return cvec_##X##_insert_range_p(self, pos.val, &value, &value + 1); \
+ return cvec_##X##_insert_range_p(self, pos.ref, &value, &value + 1); \
} \
STC_INLINE cvec_##X##_iter_t \
cvec_##X##_insert_at(cvec_##X* self, size_t idx, Value value) { \
@@ -132,11 +132,11 @@ \
STC_INLINE cvec_##X##_iter_t \
cvec_##X##_erase_range(cvec_##X* self, cvec_##X##_iter_t first, cvec_##X##_iter_t finish) { \
- return cvec_##X##_erase_range_p(self, first.val, finish.val); \
+ return cvec_##X##_erase_range_p(self, first.ref, finish.ref); \
} \
STC_INLINE cvec_##X##_iter_t \
cvec_##X##_erase(cvec_##X* self, cvec_##X##_iter_t pos) { \
- return cvec_##X##_erase_range_p(self, pos.val, pos.val + 1); \
+ return cvec_##X##_erase_range_p(self, pos.ref, pos.ref + 1); \
} \
STC_INLINE cvec_##X##_iter_t \
cvec_##X##_erase_n(cvec_##X* self, size_t idx, size_t n) { \
@@ -178,11 +178,11 @@ cvec_##X##_iter_t it = {self->data + cvec_size(*self)}; return it; \
} \
STC_INLINE void \
- cvec_##X##_next(cvec_##X##_iter_t* it) {++it->val;} \
+ cvec_##X##_next(cvec_##X##_iter_t* it) {++it->ref;} \
STC_INLINE cvec_##X##_value_t* \
- cvec_##X##_itval(cvec_##X##_iter_t it) {return it.val;} \
+ cvec_##X##_itval(cvec_##X##_iter_t it) {return it.ref;} \
STC_INLINE size_t \
- cvec_##X##_index(cvec_##X v, cvec_##X##_iter_t it) {return it.val - v.data;} \
+ cvec_##X##_index(cvec_##X v, cvec_##X##_iter_t it) {return it.ref - v.data;} \
\
_c_implement_cvec_7(X, Value, valueDestroy, RawValue, valueCompareRaw, valueToRaw, valueFromRaw) \
typedef cvec_##X cvec_##X##_t
@@ -273,8 +273,8 @@ \
STC_DEF cvec_##X##_iter_t \
cvec_##X##_find_in_range(const cvec_##X* self, cvec_##X##_iter_t first, cvec_##X##_iter_t finish, RawValue rawValue) { \
- for (; first.val != finish.val; cvec_##X##_next(&first)) { \
- RawValue r = valueToRaw(first.val); \
+ for (; first.ref != finish.ref; cvec_##X##_next(&first)) { \
+ RawValue r = valueToRaw(first.ref); \
if (valueCompareRaw(&r, &rawValue) == 0) return first; \
} \
return cvec_##X##_end(self); \
|
