|
My library
Library for common tasks
|
Common tasks with arrays: sorting, searching, printing etc. More...
#include "types.h"

Go to the source code of this file.
Functions | |
| void | chooseBubbleSortArr (const spec_t spec, void *arr, unsigned int size,...) |
| Bubble sort for arrays. More... | |
| void | chooseQuickSortArr (const spec_t spec, void *arr, int size,...) |
| Quick sort for arrays. More... | |
| int | chooseLinearSearchArr (const spec_t spec, const void *arr, int size,...) |
| Linear search for arrays. More... | |
| void | printMatrix (const spec_t spec, const void *matrix, const unsigned int nRows, const unsigned int nColumns) |
| Print a matrix of specified size with specified formatting. More... | |
| void | charBubbleSortArr (char *arr, unsigned int size) |
| Bubblesort for arrays of chars. More... | |
| void | intBubbleSortArr (int *arr, unsigned int size) |
| Bubblesort for arrays of ints. More... | |
| void | floatBubbleSortArr (float *arr, unsigned int size) |
| Bubblesort for arrays of floats. More... | |
| void | doubleBubbleSortArr (double *arr, unsigned int size) |
| Bubblesort for arrays of doubles. More... | |
| void | ptrBubbleSortArr (void **arr, unsigned int size, int(*cmpFunc)(const void *a, const void *b)) |
| Bubblesort for arrays of pointers. More... | |
| void | charQuickSortArr (char *arr, int size) |
| Quicksort for arrays of chars. More... | |
| void | intQuickSortArr (int *arr, int size) |
| Quicksort for arrays of ints. More... | |
| void | floatQuickSortArr (float *arr, int size) |
| Quicksort for arrays of floats. More... | |
| void | doubleQuickSortArr (double *arr, int size) |
| Quicksort for arrays of doubles. More... | |
| void | ptrQuickSortArr (void *arr, int size, int(*cmpFunc)(const void *a, const void *b)) |
| Quicksort for arrays of pointers. More... | |
| int | charLinearSearchArr (const char *arr, int size, char key) |
| Linear search for arrays of chars. More... | |
| int | intLinearSearchArr (const char *arr, int size, int key) |
| Linear search for arrays of integers. More... | |
| int | floatLinearSearchArr (const char *arr, int size, float key) |
| Linear search for arrays of floats. More... | |
| int | doubleLinearSearchArr (const char *arr, int size, double key) |
| Linear search for arrays of doubles. More... | |
| int | ptrLinearSearchArr (const void *arr, int size, void *key, int(*cmpFunc)(const void *a, const void *b)) |
| Linear search for arrays of pointers. More... | |
Common tasks with arrays: sorting, searching, printing etc.
| void charBubbleSortArr | ( | char * | arr, |
| unsigned int | size | ||
| ) |
Bubblesort for arrays of chars.
Equivalent to chooseBubbleSortArr("%c", arr, size). Refer to chooseBubbleSortArr()
| int charLinearSearchArr | ( | const char * | arr, |
| int | size, | ||
| char | key | ||
| ) |
Linear search for arrays of chars.
Equivalent to chooseLinearSearchArr("%c", arr, size, key). Refer to chooseQuickSortArr()
| void charQuickSortArr | ( | char * | arr, |
| int | size | ||
| ) |
Quicksort for arrays of chars.
Equivalent to chooseQuickSortArr("%c", arr, size). Refer to chooseQuickSortArr()
| void chooseBubbleSortArr | ( | const spec_t | spec, |
| void * | arr, | ||
| unsigned int | size, | ||
| ... | |||
| ) |
Bubble sort for arrays.
| spec | Type specifier of the array to be sorted. Refer to spec_t for supported types |
| arr | Pointer to the first element of the array to be sorted |
| size | Number of elements of the array to be sorted |
| ... | The comparison function needed to compare items inside given lists. This parameter is necessary only for pointer ArrayList type and is ignored otherwise. Must be a function that takes two pointers as argument and returns a positive int if the item pointed by the first argument is greater than the item pointed by the second argument, a negative int if the item pointed by the first argument is is smaller than the item pointed by second, a zero int if the item pointed by first and second arguments are equal |
| int chooseLinearSearchArr | ( | const spec_t | spec, |
| const void * | arr, | ||
| int | size, | ||
| ... | |||
| ) |
Linear search for arrays.
| spec | Type specifier of the array to be sorted. Refer to spec_t for supported types |
| arr | Pointer to the first element of the array to be inspected |
| size | Number of elements of the array to be inspected |
| ... | The key to be searched. If searaching in a pointer array, after the item you want so search, you must provide the comparison function needed to compare the item you want to search and the items in the array. Must be a function that takes two pointers as argument and returns a zero int only if the item pointed by first and second arguments are equal |
| KEY_NOT_FOUND | The key was not found |
| void chooseQuickSortArr | ( | const spec_t | spec, |
| void * | arr, | ||
| int | size, | ||
| ... | |||
| ) |
Quick sort for arrays.
| spec | Type specifier of the array to be sorted. Refer to spec_t for supported types |
| arr | Pointer to the first element of the array to be sorted |
| size | Number of elements of the array to be sorted |
| ... | The comparison function needed to compare items inside given lists. This parameter is necessary only for pointer ArrayList type and is ignored otherwise. Must be a function that takes two pointers as argument and returns a positive int if the item pointed by the first argument is greater than the item pointed by the second argument, a negative int if the item pointed by the first argument is is smaller than the item pointed by second, a zero int if the item pointed by first and second arguments are equal |
| void doubleBubbleSortArr | ( | double * | arr, |
| unsigned int | size | ||
| ) |
Bubblesort for arrays of doubles.
Equivalent to chooseBubbleSortArr("%lf", arr, size). Refer to chooseBubbleSortArr()
| int doubleLinearSearchArr | ( | const char * | arr, |
| int | size, | ||
| double | key | ||
| ) |
Linear search for arrays of doubles.
Equivalent to chooseLinearSearchArr("%lf", arr, size, key). Refer to chooseLinearSearchArr()
| void doubleQuickSortArr | ( | double * | arr, |
| int | size | ||
| ) |
Quicksort for arrays of doubles.
Equivalent to chooseQuickSortArr("%lf", arr, size). Refer to chooseQuickSortArr()
| void floatBubbleSortArr | ( | float * | arr, |
| unsigned int | size | ||
| ) |
Bubblesort for arrays of floats.
Equivalent to chooseBubbleSortArr("%f", arr, size). Refer to chooseBubbleSortArr()
| int floatLinearSearchArr | ( | const char * | arr, |
| int | size, | ||
| float | key | ||
| ) |
Linear search for arrays of floats.
Equivalent to chooseLinearSearchArr("%f", arr, size, key). Refer to chooseLinearSearchArr()
| void floatQuickSortArr | ( | float * | arr, |
| int | size | ||
| ) |
Quicksort for arrays of floats.
Equivalent to chooseQuickSortArr("%f", arr, size). Refer to chooseQuickSortArr()
| void intBubbleSortArr | ( | int * | arr, |
| unsigned int | size | ||
| ) |
Bubblesort for arrays of ints.
Equivalent to chooseBubbleSortArr("%i", arr, size). Refer to chooseBubbleSortArr()
| int intLinearSearchArr | ( | const char * | arr, |
| int | size, | ||
| int | key | ||
| ) |
Linear search for arrays of integers.
Equivalent to chooseLinearSearchArr("%i", arr, size, key). Refer to chooseLinearSearchArr()
| void intQuickSortArr | ( | int * | arr, |
| int | size | ||
| ) |
Quicksort for arrays of ints.
Equivalent to chooseQuickSortArr("%i", arr, size). Refer to chooseQuickSortArr()
| void printMatrix | ( | const spec_t | spec, |
| const void * | matrix, | ||
| const unsigned int | nRows, | ||
| const unsigned int | nColumns | ||
| ) |
Print a matrix of specified size with specified formatting.
| spec | Type and format specifier used to print a cell. The printf() identifier and formatting convention is supported. See spec_t for details. Additional supported specifiers: "%hi" (numerical output for char) |
"%5.3lf" is supported, "%5.3lf\n" or "%5.3lfTest" is not supported and nothing is printed | matrix | Pointer to the first element of the matrix |
| nRows | Number of rows of the matrix |
| nColumns | Number of rows of the matrix |
| void ptrBubbleSortArr | ( | void ** | arr, |
| unsigned int | size, | ||
| int(*)(const void *a, const void *b) | cmpFunc | ||
| ) |
Bubblesort for arrays of pointers.
| arr | The array to be sorted |
| size | The number of items contained in arr |
| cmpFunc | The comparison function needed to compare items inside given lists. Must be a function that takes two pointers as argument and returns a positive int if the item pointed by the first argument is greater than the item pointed by the second argument, a negative int if the item pointed by the first argument is is smaller than the item pointed by second, a zero int if the item pointed by first and second arguments are equal |
| int ptrLinearSearchArr | ( | const void * | arr, |
| int | size, | ||
| void * | key, | ||
| int(*)(const void *a, const void *b) | cmpFunc | ||
| ) |
Linear search for arrays of pointers.
| arr | Pointer to the first element of the array to be inspected |
| size | Number of elements of the array to be inspected |
| key | The key to be searched |
| cmpFunc | The comparison function to be used. Must be a function that returns a positive int if first argument is greater than the second, a negative byte if first argument is smaller than the second, a zero byte if first and second arguments are equal |
| KEY_NOT_FOUND | The key was not found |
| void ptrQuickSortArr | ( | void * | arr, |
| int | size, | ||
| int(*)(const void *a, const void *b) | cmpFunc | ||
| ) |
Quicksort for arrays of pointers.
| arr | The array to be sorted |
| size | The number of items contained in arr |
| cmpFunc | The comparison function to be used. Must be a function that returns a positive int if first argument is greater than the second, a negative byte if first argument is smaller than the second, a zero byte if first and second arguments are equal |