From c0bdaa745f2367812bc72290d6b7dfe2a1a149fe Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 27 Apr 2021 12:28:15 +0200 Subject: Made clist_X_find_in() arguments consistent with cvec_X_find_in() and cdeq_X_find_in(), i.e. removed self. --- benchmarks/others/clist_v1.h | 28 ++++++++++++++-------------- docs/clist_api.md | 3 +-- stc/clist.h | 8 ++++---- 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* \ -- cgit v1.2.3