summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortylov <[email protected]>2023-07-21 11:22:48 +0200
committertylov <[email protected]>2023-07-21 11:22:48 +0200
commitf3794f2b86b6f7f85096a0c2e9ca5720aed53300 (patch)
treea96e759baf995559cab0a6e32160621015276158
parentdbcc13635402bd466675f4f41e865d02abc6f918 (diff)
downloadSTC-modified-f3794f2b86b6f7f85096a0c2e9ca5720aed53300.tar.gz
STC-modified-f3794f2b86b6f7f85096a0c2e9ca5720aed53300.zip
Removed c_foreach_rv() - only worked for cvec, so not general.
-rw-r--r--README.md1
-rw-r--r--docs/ccommon_api.md3
-rw-r--r--include/stc/ccommon.h4
-rw-r--r--misc/examples/algorithms/forloops.c4
-rw-r--r--misc/examples/linkedlists/list.c4
5 files changed, 3 insertions, 13 deletions
diff --git a/README.md b/README.md
index 6bbe50ee..b49214d4 100644
--- a/README.md
+++ b/README.md
@@ -640,7 +640,6 @@ STC is generally very memory efficient. Memory usage for the different container
- Added new crand.h API & header. Old crandom.h is deprecated.
- Added `c_const_cast()` typesafe macro.
- Removed RAII macros usage from examples
-- Renamed c_foreach_r => `c_foreach_rv`
- Renamed c_flt_count(i) => `c_flt_counter(i)`
- Renamed c_flt_last(i) => `c_flt_getcount(i)`
- Renamed c_ARRAYLEN() => c_arraylen()
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 0752beb5..11d425e5 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -3,13 +3,12 @@
---
## Ranged for-loops
-### c_foreach, c_foreach_rv, c_forpair
+### c_foreach, c_forpair
| Usage | Description |
|:-----------------------------------------|:------------------------------------------|
| `c_foreach (it, ctype, container)` | Iteratate all elements |
| `c_foreach (it, ctype, it1, it2)` | Iterate the range [it1, it2) |
-| `c_foreach_rv (it, ctype, container)` | Iteratate in reverse (cstack, cvec, cdeq) |
| `c_forpair (key, val, ctype, container)` | Iterate with structured binding |
```c
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 316a8ee7..77f754fa 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -191,10 +191,6 @@ STC_INLINE intptr_t cnextpow2(intptr_t n) {
for (C##_iter it = start, *_endref = (C##_iter*)(finish).ref \
; it.ref != (C##_value*)_endref; C##_next(&it))
-#define c_foreach_rv(it, C, cnt) \
- for (C##_iter it = {.ref=C##_end(&cnt).end - 1, .end=(cnt).data - 1} \
- ; it.ref != it.end; --it.ref)
-
#define c_forpair(key, val, C, cnt) /* structured binding */ \
for (struct {C##_iter it; const C##_key* key; C##_mapped* val;} _ = {.it=C##_begin(&cnt)} \
; _.it.ref && (_.key = &_.it.ref->first, _.val = &_.it.ref->second) \
diff --git a/misc/examples/algorithms/forloops.c b/misc/examples/algorithms/forloops.c
index 300eee18..a83d4a53 100644
--- a/misc/examples/algorithms/forloops.c
+++ b/misc/examples/algorithms/forloops.c
@@ -41,10 +41,6 @@ int main(void)
c_foreach (i, IVec, vec)
printf(" %d", *i.ref);
- puts("\n\nc_foreach_r: reverse");
- c_foreach_rv (i, IVec, vec)
- printf(" %d", *i.ref);
-
puts("\n\nc_foreach in map:");
c_foreach (i, IMap, map)
printf(" (%d %d)", i.ref->first, i.ref->second);
diff --git a/misc/examples/linkedlists/list.c b/misc/examples/linkedlists/list.c
index 09591314..518cc09b 100644
--- a/misc/examples/linkedlists/list.c
+++ b/misc/examples/linkedlists/list.c
@@ -12,10 +12,10 @@ int main(void) {
const int n = 3000000;
DList list = {0};
- crand_t rng = crand_init(1234567);
+ csrand(1234567);
int m = 0;
c_forrange (n)
- DList_push_back(&list, crand_f64(&rng)*n + 100), ++m;
+ DList_push_back(&list, crandf()*n + 100), ++m;
double sum = 0.0;
printf("sumarize %d:\n", m);