pelib
2.0.0
|
00001 /* 00002 * sort.h 00003 * 00004 * Created on: 25 Jan 2012 00005 * Copyright 2012 Nicolas Melot 00006 * 00007 * This file is part of pelib. 00008 * 00009 * pelib is free software: you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation, either version 3 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * pelib is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with pelib. If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 */ 00023 00024 #ifndef SORT_H_ 00025 #define SORT_H_ 00026 00027 #include <pelib/integer.h> 00028 00029 #define PELIB_QUICKSORT_THRESHOLD 15 00030 #define PELIB_QUICKSORT_NUM_SAMPLE 10 00031 00033 struct qsort_tune 00034 { 00035 int begin; 00036 int end; 00037 int threshold; 00038 int num_sample; 00039 }; 00041 typedef struct qsort_tune qsort_tune_t; 00042 00049 int 00050 pelib_sample(array_t(int)* a, int size, int start, int stop); 00051 00057 void 00058 pelib_insertsort_window(array_t(int)* a, int begin, int end); 00060 void 00061 pelib_insertsort(array_t(int)*); 00063 void 00064 pelib_quicksort_tune(array_t(int)* array, qsort_tune_t p); 00066 void 00067 pelib_quicksort_tune_recursive(array_t(int)* array, qsort_tune_t p); 00069 void 00070 pelib_quicksort_window(array_t(int)* array, int begin, int end); 00072 void 00073 pelib_quicksort(array_t(int)*); 00075 int 00076 pelib_is_increasing(array_t(int)*); 00077 00078 #endif /* SORT_H_ */