static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
+ * @brief Search for the given data in an array.
+ *
+ * @param[in] array The array.
+ * @param[in] data need to be found.
+ * @param[out] out_idx The position of the data in the array if found.
+ * @return EINA_TRUE if found otherwise returns EINA_FALSE.
+ *
+ * This function searches for the data pointer @p data inside @p array, returning @c EINA_TRUE if found.
+ * The exact position where the pointer is found can be retrieved through @p out_idx.
+ * Please note that only the pointer is compared, not the actual data pointed by it.
+ *
+ * @since 1.23
+ */
+static inline Eina_Bool eina_array_find(const Eina_Array *array,
+ const void *data,
+ unsigned int *out_idx) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+/**
* @brief Gets a new iterator associated with an array.
*
* @param[in] array The array.
}
static inline Eina_Bool
+eina_array_find(const Eina_Array *array, const void *data, unsigned int *out_idx)
+{
+ if (!array) return EINA_FALSE;
+
+ unsigned int i = 0;
+ for (; i < array->count; i++)
+ {
+ if (array->data[i] == data)
+ {
+ if (out_idx) *out_idx = i;
+
+ return EINA_TRUE;
+ }
+ }
+ return EINA_FALSE;
+}
+
+static inline Eina_Bool
eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
{
void *data;
}
EFL_END_TEST
+EFL_START_TEST(eina_array_find_test)
+{
+ Eina_Array sea;
+ unsigned int i;
+ unsigned int out = 0;
+
+ fail_if(eina_array_find(NULL, (void*)1, NULL) != EINA_FALSE);
+
+ eina_array_step_set(&sea, sizeof(sea), 5);
+
+ for (i =1 ; i < 10 ; i++)
+ eina_array_push(&sea, (void*)i);
+
+ fail_if(eina_array_find(&sea, (void*)15, NULL) != EINA_FALSE);
+
+ fail_if(eina_array_find(&sea, (void*)5, NULL) != EINA_TRUE);
+ fail_if(eina_array_find(&sea, (void*)6, &out) != EINA_TRUE);
+ fail_if(out != 5);
+
+ eina_array_data_set(&sea, 7, (void*)99);
+ fail_if(eina_array_find(&sea, (void*)99, &out) != EINA_TRUE);
+ fail_if(out != 7);
+
+ eina_array_flush(&sea);
+
+ }
+
+EFL_END_TEST
void
eina_test_array(TCase *tc)
{
tcase_add_test(tc, eina_array_simple);
tcase_add_test(tc, eina_array_static);
tcase_add_test(tc, eina_array_remove_stuff);
+ tcase_add_test(tc, eina_array_find_test);
}