# generic-sequence-in-c-language **Repository Path**: wallacegibbon/generic-sequence-in-c-language ## Basic Information - **Project Name**: generic-sequence-in-c-language - **Description**: A generic sequence library implemented in C language. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-06 - **Last Updated**: 2024-01-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Introduction You should use generic sequence with pointer variable: ```c struct generic_sequence *s; ``` Creating the sequence and initializing it with `gs_new`: ```c s = gs_new(3, sizeof(float)); ``` Now you can `set`/`get` value `to`/`from` it. Just like normal arrays: ```c gs_set(s, 1, &float_val); ``` ```c gs_get(s, 1, &float_val); ``` Or you can use it as a stack: ```c gs_push(s, &float_val); ``` ```c gs_pop(s, &float_val); ``` You can set a comparing function for it: ```c int float_cmp(float *left, float *right) { return *left - *right; } gs_set_cmp_fn(s, (generic_sequence_cmp_fn)float_cmp); ``` Then you can sort it with: ```c gs_sort(s); ``` You should free the data when you don't need it. ```c gs_free(s); ``` ## Run tests ```sh gcc src/*.c && ./a.out ```