summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cvec.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-24 13:17:12 +0100
committerTyge Løvset <[email protected]>2023-02-24 13:17:12 +0100
commit560b1f4e4bf61ca01c27f1895b5138f6004eb717 (patch)
treeb8f0c4dba891b49c089a9a1916b75a002818f697 /include/stc/cvec.h
parent5c66bfeb3bf39774ebd14444bd23eaa2c17447d0 (diff)
downloadSTC-modified-560b1f4e4bf61ca01c27f1895b5138f6004eb717.tar.gz
STC-modified-560b1f4e4bf61ca01c27f1895b5138f6004eb717.zip
Added eq function to cdeq, clist, cmap, csmap, and fixed cmap eq.
Diffstat (limited to 'include/stc/cvec.h')
-rw-r--r--include/stc/cvec.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 130644cf..96ad1ecb 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -235,10 +235,13 @@ _cx_memb(_get_mut)(const _cx_self* self, _cx_raw raw)
STC_INLINE bool
_cx_memb(_eq)(const _cx_self* v1, const _cx_self* v2) {
+ if (v1->_len != v2->_len) return false;
_cx_iter i1 = _cx_memb(_begin)(v1), i2 = _cx_memb(_begin)(v2);
- for (; i1.ref && i2.ref; _cx_memb(_next)(&i1), _cx_memb(_next)(&i2))
- if (!i_eq(i1.ref, i2.ref)) return false;
- return !(i1.ref || i2.ref);
+ for (; i1.ref && i2.ref; _cx_memb(_next)(&i1), _cx_memb(_next)(&i2)) {
+ const _cx_raw rx = i_keyto(i1.ref), ry = i_keyto(i2.ref);
+ if (!(i_eq((&rx), (&ry)))) return false;
+ }
+ return true;
}
#endif
#ifndef i_no_cmp