ArrayList/ArrayList.c
size_t findInArrayList(ArrayList* list, const void* toFind, int (*compar)(const void*, const void*)) {
    if (list == NULL)
        return -1;
    
    for (size_t i = 0; i < list->size; i++) {
        if (compar(&toFind, &(list->elements[i])) == 0)
            return i;
    }
    return (size_t) -1;
}
/**
* Finds the given element (passed as a void pointer) when the passed function returns zero, enabling the ability to use the same compare function for both sortArrayList and findInArrayList.
*
* Returns the index of the element if found, (size_t) -1 if no match exists or there was an error
*/
Finds the given element (passed as a void pointer) when the passed function returns zero, enabling the ability to use the same compare function for both sortArrayList and findInArrayList.
Returns the index of the element if found, (size_t) -1 if no match exists or there was an error
Finds the given element ( passed as a void pointer ) when the passed function returns zero enabling the ability to use the same compare function for both sortArrayList and findInArrayList . Returns the index of the element if found ( size_t ) - 1 if no match exists or there was an error
size_t findInArrayList(ArrayList* list, const void* toFind, int (*compar)(const void*, const void*)) {
    if (list == NULL)
        return -1;
    for (size_t i = 0; i < list->size; i++) {
        if (compar(&toFind, &(list->elements[i])) == 0)
            return i;
    }
    return (size_t) -1;
}
size_t findInArrayList ( ArrayList * list , const void * toFind , int ( * compar ) ( const void * , const void * ) ) { if ( list == NULL ) return -1 ; for ( size_t i = 0 ; i < list -> size ; i ++ ) { if ( compar ( & toFind , & ( list -> elements [ i ] ) ) == 0 ) return i ; } return ( size_t ) -1 ; }
Finds the given element (passed as a void pointer) when the passed function returns zero, enabling the ability to use the same compare function for both sortArrayList and findInArrayList.
Finds the given element ( passed as a void pointer ) when the passed function returns zero enabling the ability to use the same compare function for both sortArrayList and findInArrayList .