summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-04-27 12:28:15 +0200
committerTyge Løvset <[email protected]>2021-04-27 12:39:33 +0200
commitc0bdaa745f2367812bc72290d6b7dfe2a1a149fe (patch)
tree96b3758adf97debc3f257d2fc821f9b4e74ed9ff
parent229797dbffd91cb12dc3930dc185ea63e5eb0896 (diff)
downloadSTC-modified-c0bdaa745f2367812bc72290d6b7dfe2a1a149fe.tar.gz
STC-modified-c0bdaa745f2367812bc72290d6b7dfe2a1a149fe.zip
Made clist_X_find_in() arguments consistent with cvec_X_find_in() and cdeq_X_find_in(), i.e. removed self.
-rw-r--r--benchmarks/others/clist_v1.h28
-rw-r--r--docs/clist_api.md3
-rw-r--r--stc/clist.h8
3 files changed, 19 insertions, 20 deletions
diff --git a/benchmarks/others/clist_v1.h b/benchmarks/others/clist_v1.h
index 9d832434..c2fd7164 100644
--- a/benchmarks/others/clist_v1.h
+++ b/benchmarks/others/clist_v1.h
@@ -108,14 +108,14 @@ STC_API size_t _clist_count(const clist_VOID* self);
STC_API CX CX##_split_after(CX* self, CX##_iter_t pos1, CX##_iter_t pos2); \
STC_API void CX##_splice_after(CX* self, CX##_iter_t pos, CX* other); \
STC_DEF void CX##_splice_after_range(CX* self, CX##_iter_t pos, CX* other, CX##_iter_t i1, CX##_iter_t i2); \
- STC_API CX##_iter_t CX##_find_before_in(const CX* self, CX##_iter_t first, CX##_iter_t finish, RawValue val); \
- STC_API CX##_iter_t CX##_find_before(const CX* self, RawValue val); \
STC_API CX##_iter_t CX##_find(const CX* self, RawValue val); \
+ STC_API CX##_iter_t CX##_find_before(const CX* self, RawValue val); \
+ STC_API CX##_iter_t CX##_find_before_in(CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
STC_API void CX##_sort(CX* self); \
STC_API size_t CX##_remove(CX* self, RawValue val); \
STC_API CX##_iter_t CX##_insert_after(CX* self, CX##_iter_t pos, Value value); \
STC_API CX##_iter_t CX##_erase_after(CX* self, CX##_iter_t pos); \
- STC_API CX##_iter_t CX##_erase_range_after(CX* self, CX##_iter_t pos, CX##_iter_t finish); \
+ STC_API CX##_iter_t CX##_erase_range_after(CX* self, CX##_iter_t pos, CX##_iter_t it2); \
STC_API CX##_node_t* CX##_erase_after_(CX* self, CX##_node_t* node); \
\
STC_INLINE CX CX##_init(void) {CX lst = {NULL}; return lst;} \
@@ -229,33 +229,33 @@ STC_API size_t _clist_count(const clist_VOID* self);
} \
\
STC_DEF CX##_iter_t \
- CX##_erase_range_after(CX* self, CX##_iter_t first, CX##_iter_t finish) { \
- CX##_node_t* node = _clist_node(CX, first.ref), *done = finish.ref ? _clist_node(CX, finish.ref) : NULL; \
+ CX##_erase_range_after(CX* self, CX##_iter_t it1, CX##_iter_t it2) { \
+ CX##_node_t* node = _clist_node(CX, it1.ref), *done = it2.ref ? _clist_node(CX, it2.ref) : NULL; \
while (node && node->next != done) \
node = CX##_erase_after_(self, node); \
- CX##_next(&first); return first; \
+ CX##_next(&it1); return it1; \
} \
\
STC_DEF CX##_iter_t \
- CX##_find_before_in(const CX* self, CX##_iter_t first, CX##_iter_t finish, RawValue val) { \
- CX##_iter_t i = first; \
- for (CX##_next(&i); i.ref != finish.ref; CX##_next(&i)) { \
+ CX##_find_before_in(CX##_iter_t it1, CX##_iter_t it2, RawValue val) { \
+ CX##_iter_t i = it1; \
+ for (CX##_next(&i); i.ref != it2.ref; CX##_next(&i)) { \
RawValue r = valueToRaw(i.ref); \
- if (valueCompareRaw(&r, &val) == 0) return first; \
- first = i; \
+ if (valueCompareRaw(&r, &val) == 0) return it1; \
+ it1 = i; \
} \
- return CX##_end(self); \
+ it1.ref = NULL; return it1; \
} \
\
STC_DEF CX##_iter_t \
CX##_find_before(const CX* self, RawValue val) { \
- CX##_iter_t it = CX##_find_before_in(self, CX##_before_begin(self), CX##_end(self), val); \
+ CX##_iter_t it = CX##_find_before_in(CX##_before_begin(self), CX##_end(self), val); \
return it; \
} \
\
STC_DEF CX##_iter_t \
CX##_find(const CX* self, RawValue val) { \
- CX##_iter_t it = CX##_find_before_in(self, CX##_before_begin(self), CX##_end(self), val); \
+ CX##_iter_t it = CX##_find_before_in(CX##_before_begin(self), CX##_end(self), val); \
if (it.ref != CX##_end(self).ref) CX##_next(&it); \
return it; \
} \
diff --git a/docs/clist_api.md b/docs/clist_api.md
index 5c59be8a..09efb22e 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -77,8 +77,7 @@ clist_X_iter_t clist_X_splice_range(clist_X* self, clist_X_iter_t it,
clist_X* other, clist_X_iter_t it1, clist_X_iter_t it2);
clist_X_iter_t clist_X_find(const clist_X* self, RawValue raw);
-clist_X_iter_t clist_X_find_in(const clist_X* self,
- clist_X_iter_t it1, clist_X_iter_t it2, RawValue raw);
+clist_X_iter_t clist_X_find_in(clist_X_iter_t it1, clist_X_iter_t it2, RawValue raw);
void clist_X_sort(clist_X* self);
diff --git a/stc/clist.h b/stc/clist.h
index 1d10c807..dbdac503 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -111,7 +111,7 @@ STC_API size_t _clist_count(const clist_VOID* self);
STC_API CX##_iter_t CX##_splice(CX* self, CX##_iter_t it, CX* other); \
STC_API CX CX##_split(CX* self, CX##_iter_t it1, CX##_iter_t it2); \
STC_API void CX##_sort(CX* self); \
- STC_API CX##_iter_t CX##_find_in(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
+ STC_API CX##_iter_t CX##_find_in(CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
STC_API CX##_node_t* CX##_erase_after_(CX* self, CX##_node_t* node); \
\
STC_INLINE CX CX##_init(void) {CX lst = {NULL}; return lst;} \
@@ -172,7 +172,7 @@ STC_API size_t _clist_count(const clist_VOID* self);
\
STC_INLINE CX##_iter_t \
CX##_find(const CX* self, RawValue val) { \
- return CX##_find_in(self, CX##_begin(self), CX##_end(self), val); \
+ return CX##_find_in(CX##_begin(self), CX##_end(self), val); \
} \
\
_c_implement_clist(CX, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
@@ -242,12 +242,12 @@ STC_API size_t _clist_count(const clist_VOID* self);
} \
\
STC_DEF CX##_iter_t \
- CX##_find_in(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val) { \
+ CX##_find_in(CX##_iter_t it1, CX##_iter_t it2, RawValue val) { \
c_foreach_4 (it, CX, it1, it2) { \
RawValue r = valueToRaw(it.ref); \
if (valueCompareRaw(&r, &val) == 0) return it; \
} \
- return CX##_end(self); \
+ it2.ref = NULL; return it2; \
} \
\
STC_DEF CX##_node_t* \