0

I've used in the past the list manipulation library available in LabWindows (an industrial C compiler+libraries). It's quite easy to use and I'm looking for a similar replacement I can use on standard Linux C code. I've always been surprised that standard C has qsort and a few other generic functions, but no generic list function. So, anybody knows a similar open-source library ?

Here's an example:

#include <toolbox.h>
int Compare(void *item1, void *item2) {
    return *(double*)item1 - *(double*)item2;
}

void main (void) {
    ListType List = ListCreate(sizeof(double));

    for (int index = 0; index < 360; index++) {
        double value = sin (PI * index / 180);
        ListInsertItem(List, &value, END_OF_LIST);
    }

    YGraphPopup("Plot Of Data In List", ListGetDataPtr(List), ListNumItems(List), VAL_DOUBLE);
    
    if (!ListIsSorted(List, Compare))
        ListQuickSort(List, Compare);
    YGraphPopup("Plot Of Data In List", ListGetDataPtr(List), ListNumItems(List), VAL_DOUBLE);

    ListDispose(List);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.