diff options
| author | Tyge Løvset <[email protected]> | 2023-02-24 11:26:53 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-24 11:26:53 +0100 |
| commit | 84e75e1b5039c3e04d9683ec7d8302f1a824b5cb (patch) | |
| tree | a3229848ed987974e00638fb844a6ff7aa3099c6 | |
| parent | 35e872ec6c0c23b0843e81ff886fc7f5742670b1 (diff) | |
| download | STC-modified-84e75e1b5039c3e04d9683ec7d8302f1a824b5cb.tar.gz STC-modified-84e75e1b5039c3e04d9683ec7d8302f1a824b5cb.zip | |
Allow to have both i_no_cmp and i_eq defined.
| -rw-r--r-- | include/stc/cdeq.h | 15 | ||||
| -rw-r--r-- | include/stc/clist.h | 14 | ||||
| -rw-r--r-- | include/stc/cvec.h | 15 | ||||
| -rw-r--r-- | include/stc/priv/template.h | 4 |
4 files changed, 35 insertions, 13 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 8ca06ada..3a21097d 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -59,8 +59,10 @@ STC_API _cx_iter _cx_memb(_emplace_range)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, const _cx_raw* p2); #endif // i_no_emplace -#if !defined i_no_cmp +#if !defined i_no_cmp || defined _i_has_eq STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, _cx_raw raw); +#endif +#ifndef i_no_cmp STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); #endif STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_key value); @@ -177,7 +179,7 @@ _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, _cx_raw raw) { } #endif // !i_no_emplace -#if !defined i_no_cmp +#if !defined i_no_cmp || defined _i_has_eq STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, _cx_raw raw) { @@ -193,6 +195,9 @@ STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, _cx_raw raw) { return (_cx_value *) _cx_memb(_get)(self, raw); } +#endif +#ifndef i_no_cmp + STC_INLINE void _cx_memb(_sort_range)(_cx_iter i1, _cx_iter i2, int(*cmp)(const _cx_value*, const _cx_value*)) { qsort(i1.ref, (size_t)(_it2_ptr(i1, i2) - i1.ref), sizeof *i1.ref, @@ -405,8 +410,7 @@ _cx_memb(_emplace_range)(_cx_self* self, _cx_value* pos, } #endif // !i_no_emplace -#if !defined i_no_cmp - +#if !defined i_no_cmp || defined _i_has_eq STC_DEF _cx_iter _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { const _cx_value* p2 = _it2_ptr(i1, i2); @@ -418,7 +422,8 @@ _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { i2.ref = NULL; return i2; } - +#endif +#ifndef i_no_cmp STC_DEF int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { const _cx_raw rx = i_keyto(x); diff --git a/include/stc/clist.h b/include/stc/clist.h index e6423c53..6fd7252d 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -99,9 +99,11 @@ STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_key value); STC_API _cx_iter _cx_memb(_insert_at)(_cx_self* self, _cx_iter it, i_key value); STC_API _cx_iter _cx_memb(_erase_at)(_cx_self* self, _cx_iter it); STC_API _cx_iter _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2); -#if !defined i_no_cmp -STC_API intptr_t _cx_memb(_remove)(_cx_self* self, _cx_raw val); +#if !defined i_no_cmp || defined _i_has_eq STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw val); +STC_API intptr_t _cx_memb(_remove)(_cx_self* self, _cx_raw val); +#endif +#ifndef i_no_cmp STC_API int _cx_memb(_sort_cmp_)(const _cx_node* x, const _cx_node* y); #endif STC_API void _cx_memb(_reverse)(_cx_self* self); @@ -188,7 +190,7 @@ _cx_memb(_splice_range)(_cx_self* self, _cx_iter it, return _cx_memb(_splice)(self, it, &tmp); } -#if !defined i_no_cmp +#if !defined i_no_cmp || defined _i_has_eq STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, _cx_raw val) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val); @@ -203,6 +205,8 @@ STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, _cx_raw val) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val).ref; } +#endif +#ifndef i_no_cmp STC_INLINE void _cx_memb(_sort)(_cx_self* self) { @@ -401,7 +405,7 @@ _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2) { return lst; } -#if !defined i_no_cmp +#if !defined i_no_cmp || defined _i_has_eq STC_DEF _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw val) { @@ -428,6 +432,8 @@ _cx_memb(_remove)(_cx_self* self, _cx_raw val) { } while (node != self->last); return n; } +#endif +#ifndef i_no_cmp STC_DEF int _cx_memb(_sort_cmp_)(const _cx_node* x, const _cx_node* y) { diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 88153912..8d5a5c87 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -87,9 +87,11 @@ STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, STC_API _cx_iter _cx_memb(_insert_range)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2); STC_API _cx_iter _cx_memb(_insert_uninit)(_cx_self* self, _cx_value* pos, const intptr_t n); -#if !defined i_no_cmp -STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); +#if !defined i_no_cmp || defined _i_has_eq STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw raw); +#endif +#ifndef i_no_cmp +STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); STC_API _cx_iter _cx_memb(_binary_search_in)(_cx_iter it1, _cx_iter it2, _cx_raw raw, _cx_iter* lower_bound); #endif STC_INLINE void _cx_memb(_value_drop)(_cx_value* val) { i_keydrop(val); } @@ -215,7 +217,7 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, size_t n) STC_INLINE intptr_t _cx_memb(_index)(const _cx_self* self, _cx_iter it) { return (it.ref - self->data); } -#if !defined i_no_cmp +#if !defined i_no_cmp || defined _i_has_eq STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, _cx_raw raw) { @@ -231,6 +233,9 @@ STC_INLINE _cx_value* _cx_memb(_get_mut)(const _cx_self* self, _cx_raw raw) { return (_cx_value*) _cx_memb(_get)(self, raw); } +#endif +#ifndef i_no_cmp + STC_INLINE _cx_iter _cx_memb(_binary_search)(const _cx_self* self, _cx_raw raw) { _cx_iter lower; @@ -383,7 +388,7 @@ _cx_memb(_emplace_range)(_cx_self* self, _cx_value* pos, } #endif // !i_no_emplace -#if !defined i_no_cmp +#if !defined i_no_cmp || defined _i_has_eq STC_DEF _cx_iter _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { const _cx_value* p2 = _it2_ptr(i1, i2); @@ -395,6 +400,8 @@ _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { i2.ref = NULL; return i2; } +#endif +#ifndef i_no_cmp STC_DEF _cx_iter _cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, const _cx_raw raw, diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h index 3fddb998..e352f488 100644 --- a/include/stc/priv/template.h +++ b/include/stc/priv/template.h @@ -105,6 +105,9 @@ #if c_option(c_no_emplace) #define i_no_emplace #endif +#ifdef i_eq + #define _i_has_eq +#endif #if defined i_key_str #define i_keyclass cstr @@ -342,5 +345,6 @@ #undef _i_prefix #undef _i_expandby #undef _i_has_from +#undef _i_has_eq #undef _i_template #endif |
