summaryrefslogtreecommitdiffhomepage
path: root/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-12-17 07:55:59 +0100
committerTyge Løvset <[email protected]>2020-12-17 07:55:59 +0100
commitbc2981ee8fa3cba0be0d0efb1e2a2072c98ca5a0 (patch)
tree2e848e43a77cf4507645d7b89231c9a726b3ec05 /stc
parent214a2aa75d164d285661719131f54c71fa2f8e37 (diff)
downloadSTC-modified-bc2981ee8fa3cba0be0d0efb1e2a2072c98ca5a0.tar.gz
STC-modified-bc2981ee8fa3cba0be0d0efb1e2a2072c98ca5a0.zip
API change: Reverted back to original name used for .val in iterators to .ref
Diffstat (limited to 'stc')
-rw-r--r--stc/carray.h6
-rw-r--r--stc/cbitset.h6
-rw-r--r--stc/ccommon.h4
-rw-r--r--stc/clist.h32
-rw-r--r--stc/cmap.h16
-rw-r--r--stc/cptr.h2
-rw-r--r--stc/cstr.h6
-rw-r--r--stc/cvec.h20
8 files changed, 46 insertions, 46 deletions
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; \
diff --git a/stc/cmap.h b/stc/cmap.h
index 1dfa2582..dfaf0447 100644
--- a/stc/cmap.h
+++ b/stc/cmap.h
@@ -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; \
} \
\
diff --git a/stc/cptr.h b/stc/cptr.h
index d5d7bc3b..a3ec625f 100644
--- a/stc/cptr.h
+++ b/stc/cptr.h
@@ -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);
}
*/
diff --git a/stc/cstr.h b/stc/cstr.h
index 71853621..aad1d7fc 100644
--- a/stc/cstr.h
+++ b/stc/cstr.h
@@ -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) {
diff --git a/stc/cvec.h b/stc/cvec.h
index 53f5927d..943de06f 100644
--- a/stc/cvec.h
+++ b/stc/cvec.h
@@ -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); \