summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cqueue.h
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-05-19 19:06:37 +0200
committerTyge Lovset <[email protected]>2023-05-19 19:06:37 +0200
commitd629139d053fdc1ff24bc0dc1985e1a2d1a0ac47 (patch)
tree86af3209ee9f11d38cbb053ee658b0f2dae6565d /include/stc/cqueue.h
parent424e522d6f081bb8649777a3376e1dd5913daac8 (diff)
downloadSTC-modified-d629139d053fdc1ff24bc0dc1985e1a2d1a0ac47.tar.gz
STC-modified-d629139d053fdc1ff24bc0dc1985e1a2d1a0ac47.zip
Added container equality function to docs _eq(c1, c2).
Diffstat (limited to 'include/stc/cqueue.h')
-rw-r--r--include/stc/cqueue.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h
index 840c4fa6..1f2c7d0f 100644
--- a/include/stc/cqueue.h
+++ b/include/stc/cqueue.h
@@ -62,6 +62,10 @@ STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw)
{ return _cx_memb(_push)(self, i_keyfrom(raw)); }
#endif
+#if defined _i_has_eq || defined _i_has_cmp
+STC_API bool _cx_memb(_eq)(const _cx_self* self, const _cx_self* other);
+#endif
+
#if !defined i_no_clone
STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
STC_INLINE i_key _cx_memb(_value_clone)(i_key val)
@@ -211,6 +215,20 @@ _cx_memb(_clone)(_cx_self cx) {
return out;
}
#endif // i_no_clone
+
+#if defined _i_has_eq || defined _i_has_cmp
+STC_DEF bool
+_cx_memb(_eq)(const _cx_self* self, const _cx_self* other) {
+ if (_cx_memb(_size)(self) != _cx_memb(_size)(other)) return false;
+ for (_cx_iter i = _cx_memb(_begin)(self), j = _cx_memb(_begin)(other);
+ i.ref; _cx_memb(_next)(&i), _cx_memb(_next)(&j))
+ {
+ const _cx_raw _rx = i_keyto(i.ref), _ry = i_keyto(j.ref);
+ if (!(i_eq((&_rx), (&_ry)))) return false;
+ }
+ return true;
+}
+#endif
#endif // IMPLEMENTATION
#include "priv/template2.h"
#define CQUEUE_H_INCLUDED