/*
 * Copyright 2011 Steven Gribble
 *
 *  This file is part of the UW CSE 333 course project sequence
 *  (333proj).
 *
 *  333proj is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  333proj is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with 333proj.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _LEC10_SORT_H_
#define _LEC10_SORT_H_

#include <stdint.h>

// Defines a function pointer used to compare two elements in
// an array; used by sort.  Function returns 1 if el1 > el2,
// 0 if el1 == el2, -1 if el1 < el2.
typedef int(*ComparatorFnPtr)(void *el1, void *el2);

// Uses quicksort to sort an array of elements.
//
// arr: points at the first array element
// num_elements: # of elements in the array
// element_size: size of an array element
// f: a pointer to a function used to compare two array elements
void QuickSort(void *arr, uint32_t num_elements, uint32_t element_size,
               ComparatorFnPtr f);

// Uses bubblesort to sort an array of elements.
//
// arr: points at the first array element
// num_elements: # of elements in the array
// element_size: size of an array element
// f: a pointer to a function used to compare two array elements
void BubbleSort(void *arr, uint32_t num_elements, uint32_t element_size,
                ComparatorFnPtr f);

#endif  // _LEC10_SORT_H_