--- /dev/null
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_vec_is_equal.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/06/28 14:07:57 by ljiriste #+# #+# */
+/* Updated: 2024/06/28 14:12:53 by ljiriste ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "ft_arr.h"
+
+int ft_vec_is_equal(const t_vec *vec1, const t_vec *vec2,
+ int (*cmp_elements)(const void *, const void *))
+{
+ size_t i;
+ const void *el1;
+ const void *el2;
+
+ if (vec1->size != vec2->size)
+ return (0);
+ i = 0;
+ while (i < vec1->size)
+ {
+ el1 = ft_vec_caccess(vec1, i);
+ el2 = ft_vec_caccess(vec2, i);
+ if (cmp_elements(el1, el2) != 0)
+ return (0);
+ }
+ return (1);
+}
/* By: ljiriste <ljiriste@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/09 13:58:15 by ljiriste #+# #+# */
-/* Updated: 2024/06/28 13:47:36 by ljiriste ### ########.fr */
+/* Updated: 2024/06/28 14:11:56 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
void *ft_vec_find(t_vec *vec, void *wanted);
t_arr_stat ft_vec_find_index(t_vec *vec, void *wanted, size_t *index);
+int ft_vec_is_equal(const t_vec *vec1, const t_vec *vec2,
+ int (*cmp_elements)(const void *, const void *));
+
// The following are functions that would operate on sets.
// I have not implemented set structure as it would be just a wrapper
// on t_vec with worsened access to the elements.