diff options
| author | Tyge Løvset <[email protected]> | 2021-09-08 10:24:45 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-09-08 10:24:45 +0200 |
| commit | 74a737adf39cf6416195dc9a9c83fd46362416a6 (patch) | |
| tree | 46b7048f60017eb72442dbf4d9073d53246431a6 | |
| parent | c40cb13574d0b00da2ff151de81b701e29b80e10 (diff) | |
| download | STC-modified-74a737adf39cf6416195dc9a9c83fd46362416a6.tar.gz STC-modified-74a737adf39cf6416195dc9a9c83fd46362416a6.zip | |
Improved undocumented iterator method names: fwd, adv => advance, idx => index.
| -rw-r--r-- | include/stc/cdeq.h | 5 | ||||
| -rw-r--r-- | include/stc/clist.h | 2 | ||||
| -rw-r--r-- | include/stc/clist_v1.h | 2 | ||||
| -rw-r--r-- | include/stc/cmap.h | 9 | ||||
| -rw-r--r-- | include/stc/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/csmap_v1.h | 2 | ||||
| -rw-r--r-- | include/stc/cstack.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 9 |
8 files changed, 22 insertions, 11 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index b941d6c5..f384644e 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -80,8 +80,9 @@ STC_INLINE cx_iter_t cx_memb(_begin)(const Self* self) STC_INLINE cx_iter_t cx_memb(_end)(const Self* self)
{ return c_make(cx_iter_t){self->data + cdeq_rep_(self)->size}; }
STC_INLINE void cx_memb(_next)(cx_iter_t* it) { ++it->ref; }
-STC_INLINE cx_iter_t cx_memb(_adv)(cx_iter_t it, intptr_t offs) { it.ref += offs; return it; }
-STC_INLINE size_t cx_memb(_idx)(Self cx, cx_iter_t it) { return it.ref - cx.data; }
+STC_INLINE cx_iter_t cx_memb(_advance)(cx_iter_t it, intptr_t offs)
+ { it.ref += offs; return it; }
+STC_INLINE size_t cx_memb(_index)(Self cx, cx_iter_t it) { return it.ref - cx.data; }
STC_INLINE Self
cx_memb(_with_capacity)(size_t n) {
diff --git a/include/stc/clist.h b/include/stc/clist.h index 8bca82e2..12be1146 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -215,7 +215,7 @@ cx_memb(_next)(cx_iter_t* it) { }
STC_INLINE cx_iter_t
-cx_memb(_fwd)(cx_iter_t it, size_t n) {
+cx_memb(_advance)(cx_iter_t it, size_t n) {
while (n-- && it.ref) cx_memb(_next)(&it);
return it;
}
diff --git a/include/stc/clist_v1.h b/include/stc/clist_v1.h index e19b2764..10d8092e 100644 --- a/include/stc/clist_v1.h +++ b/include/stc/clist_v1.h @@ -139,7 +139,7 @@ STC_API size_t _clist_count(const clist_VOID* self); } \
\
STC_INLINE cx_iter_t \
- cx_memb(_fwd)(cx_iter_t it, size_t n) { \
+ cx_memb(_advance)(cx_iter_t it, size_t n) { \
while (n-- && it.ref) cx_memb(_next)(&it); return it; \
} \
\
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 943c883a..e2f277ee 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -215,7 +215,14 @@ cx_memb(_end)(const Self* self) STC_INLINE void
cx_memb(_next)(cx_iter_t* it)
- {while ((++it->ref, *++it->_hx == 0)) ; }
+ { while ((++it->ref, *++it->_hx == 0)) ; }
+
+STC_INLINE cx_iter_t
+cx_memb(_advance)(cx_iter_t it, size_t n) {
+ // UB if n > elements left
+ while (n--) cx_memb(_next)(&it);
+ return it;
+}
STC_INLINE size_t
cx_memb(_erase)(Self* self, i_keyraw rkey) {
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index dbee8fc9..df536463 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -194,7 +194,7 @@ cx_memb(_end)(const Self* self) { }
STC_INLINE cx_iter_t
-cx_memb(_fwd)(cx_iter_t it, size_t n) {
+cx_memb(_advance)(cx_iter_t it, size_t n) {
while (n-- && it.ref) cx_memb(_next)(&it);
return it;
}
diff --git a/include/stc/csmap_v1.h b/include/stc/csmap_v1.h index b9f443a8..88c3967a 100644 --- a/include/stc/csmap_v1.h +++ b/include/stc/csmap_v1.h @@ -185,7 +185,7 @@ int main(void) { } \
\
STC_INLINE cx_iter_t \
- cx_memb(_fwd)(cx_iter_t it, size_t n) { \
+ cx_memb(_advance)(cx_iter_t it, size_t n) { \
while (n-- && it.ref) cx_memb(_next)(&it); \
return it; \
} \
diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 448b6c2f..42717ee8 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -90,5 +90,7 @@ STC_INLINE cx_iter_t cx_memb(_begin)(const Self* self) STC_INLINE cx_iter_t cx_memb(_end)(const Self* self)
{ return c_make(cx_iter_t){self->data + self->size}; }
STC_INLINE void cx_memb(_next)(cx_iter_t* it) { ++it->ref; }
+STC_INLINE cx_iter_t cx_memb(_advance)(cx_iter_t it, intptr_t offs)
+ { it.ref += offs; return it; }
#include "template.h"
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 513870ed..f9f62439 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -98,7 +98,7 @@ STC_INLINE i_val cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom STC_INLINE i_valraw cx_memb(_value_toraw)(cx_value_t* val) { return i_valto(val); }
STC_INLINE i_val cx_memb(_value_clone)(cx_value_t val)
{ return i_valfrom(i_valto(&val)); }
-STC_INLINE void cx_memb(_swap)(Self* a, Self* b) {c_swap(Self, *a, *b); }
+STC_INLINE void cx_memb(_swap)(Self* a, Self* b) { c_swap(Self, *a, *b); }
STC_INLINE cx_value_t* cx_memb(_front)(const Self* self) { return self->data; }
STC_INLINE cx_value_t* cx_memb(_back)(const Self* self)
{ return self->data + cvec_rep_(self)->size - 1; }
@@ -110,9 +110,10 @@ STC_INLINE cx_iter_t cx_memb(_begin)(const Self* self) { return c_make(cx_iter_t){self->data}; }
STC_INLINE cx_iter_t cx_memb(_end)(const Self* self)
{ return c_make(cx_iter_t){self->data + cvec_rep_(self)->size}; }
-STC_INLINE void cx_memb(_next)(cx_iter_t* it) {++it->ref; }
-STC_INLINE cx_iter_t cx_memb(_adv)(cx_iter_t it, intptr_t offs) {it.ref += offs; return it; }
-STC_INLINE size_t cx_memb(_idx)(Self cx, cx_iter_t it) { return it.ref - cx.data; }
+STC_INLINE void cx_memb(_next)(cx_iter_t* it) { ++it->ref; }
+STC_INLINE cx_iter_t cx_memb(_advance)(cx_iter_t it, intptr_t offs)
+ { it.ref += offs; return it; }
+STC_INLINE size_t cx_memb(_index)(Self cx, cx_iter_t it) { return it.ref - cx.data; }
STC_INLINE Self
cx_memb(_with_size)(size_t size, i_val null_val) {
|
