=encoding UTF-8 =head1 NAME BH_Algo - General algorithms =head1 SYNTAX #include int data[4] = {5, 2, 3, 1}; int value, i; value = 4; BH_Partition(&value, data, 4, sizeof(int), intEqual); BH_Sort(data, 4, sizeof(int), intEqual); BH_HeapMake(data, 4, sizeof(int), intEqual); cc prog.c -o prog -lbh =head1 DESCRIPTION The BH_Algo library provides a set of algorithms for working with data: =over =item * Value swapping (L) =item * Array partitioning (L) =item * Sorting (L) =item * Heap operations (L, L, L, L) =back These algorithms allow you to efficiently perform various operations on arrays and other data structures. =head1 API CALLS =head2 BH_Swap void BH_Swap(void *dest, void *src, size_t size); Swaps the values between the variables I and I of the specified size I. =head2 BH_Partition void *BH_Partition(void *pivot, void *array, size_t size, size_t element, BH_EqualCallback equal); Partitions the array of elements I (with the number of elements I and the size of the element I) into two groups relative to the pivot element I. The I parameter takes a pointer to a function that compares two elements. The I parameter can refer to an element of the array being partitioned. The function returns a pointer to the first element of the array that belongs to the second group. =head2 BH_Sort void BH_Sort(void *array, size_t size, size_t element, BH_EqualCallback equal); Sorts the array of elements I (with the number of elements I and the size of the element I). The I parameter takes a pointer to a function that compares two elements. =head2 BH_HeapMake void BH_HeapMake(void *array, size_t size, size_t element, BH_EqualCallback equal); Creates a heap in the array I (with the number of elements I and the size of the element I). The I parameter takes a pointer to a function that compares two elements. =head2 BH_HeapRemove void BH_HeapRemove(void *array, size_t size, size_t element, BH_EqualCallback equal); Extracts the top element of the heap in the array I (with the number of elements I and the size of the element I). The I parameter takes a pointer to a function that compares two elements. =head2 BH_HeapInsert void BH_HeapInsert(void *value, void *array, size_t size, size_t element, BH_EqualCallback equal); Adds the element I to the heap in the array I (with the number of elements I and the size of the element I). If I is NULL, it is assumed that the new value is at the end of the array. The I parameter takes a pointer to a function that compares two elements. =head2 BH_HeapReplace void BH_HeapReplace(void *value, void *array, size_t size, size_t element, BH_EqualCallback equal); Extracts the top element of the heap in the array I (with the number of elements I and the size of the element I) and adds the element I to it. If I is NULL, it is assumed that the new value is at the end of the array. The I parameter takes a pointer to a function that compares two elements. =head1 SEE ALSO L