|
From: <ad...@us...> - 2006-03-07 13:46:39
|
Revision: 35 Author: adamluk Date: 2006-03-07 05:46:19 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/g3l/?rev=35&view=rev Log Message: ----------- Modified Paths: -------------- ProjectManager/trunk/include/includer.php src/trunk/source/G3L_ENGINE/algorithms/.g3l_quicksort.cpp.swp src/trunk/source/G3L_ENGINE/algorithms/g3l_quicksort.cpp Added Paths: ----------- src/trunk/source/G3L_ENGINE/algorithms/g3l_bubblesort.cpp src/trunk/source/G3L_ENGINE/algorithms/g3l_heapsort.cpp Modified: ProjectManager/trunk/include/includer.php =================================================================== --- ProjectManager/trunk/include/includer.php 2006-03-07 00:12:23 UTC (rev 34) +++ ProjectManager/trunk/include/includer.php 2006-03-07 13:46:19 UTC (rev 35) @@ -16,14 +16,7 @@ require(DIR_ROOT.'lib/db/database.php'); switch ($dbtype) - { - case 'mysql': - global $db_host, $db_user, $db_pass, $db_name; - require_once(DIR_ROOT.'lib/db/mysql_driver.php'); - $db = new mysql_driver($db_host, $db_user, $db_pass, $db_name); - - break; - + { case 'mysqli': # MySQLi Support - The Improved Faster MySQL PHP Module global $db_host, $db_user, $db_pass, $db_name; @@ -33,9 +26,10 @@ //scope for more db types - default: + case 'mysql': default: + global $db_host, $db_user, $db_pass, $db_name; require_once(DIR_ROOT.'lib/db/mysql_driver.php'); - $db = new mysql_driver($db_host, $db_user, $db_pass, $db_name); + $db = new mysql_driver($db_host, $db_user, $db_pass, $db_name); break; } } @@ -67,21 +61,18 @@ switch($settings['language']) { - case 'english': - require_once(DIR_ROOT.'lang/en/error_strings.php'); - require_once(DIR_ROOT.'lang/en/user_strings.php'); - break; - + //scope for more langs - - - //english as default - default: + + case 'english': default: + # No need to make 2 case statements! require_once(DIR_ROOT.'lang/en/error_strings.php'); require_once(DIR_ROOT.'lang/en/user_strings.php'); break; + + } } \ No newline at end of file Modified: src/trunk/source/G3L_ENGINE/algorithms/.g3l_quicksort.cpp.swp =================================================================== (Binary files differ) Added: src/trunk/source/G3L_ENGINE/algorithms/g3l_bubblesort.cpp =================================================================== --- src/trunk/source/G3L_ENGINE/algorithms/g3l_bubblesort.cpp (rev 0) +++ src/trunk/source/G3L_ENGINE/algorithms/g3l_bubblesort.cpp 2006-03-07 13:46:19 UTC (rev 35) @@ -0,0 +1,51 @@ +/* + * G3L - Generation Three Language + * The New Modern Programming Language + * + * http://www.G3L.net + * g3l...@li... + * + * This project is released under the terms of the GNU General Public Licence. + * You can Read the license here: http://www.gnu.org/licenses/gpl.html +/* + +/* + * Short Description + * + * @author Adam Livesley <ada...@gm...> + * @copyright Copyright (c) 2005 G3L Dev Team. + * @licence GPL + * @version 1.00.0a + * @category G3L_ENGINE + * @package G3L + * @todo none + * @date 07/03/06 + */ + +#include <G3L_ENGINE/algorithms/g3l_bubblesort.h> + +/* + * This is a simple Bubblesort method, it doesnt do anything extra and it shouldnt! + */ + +G3L_Bubblesort::Q3L_Bubblesort(int *array, int length) { + int i, j; + int temp; + int check; + + for (i = length - 1; i > 0; i--) { + check=1; + for (j =0; j < i; j++) { + if (array[j] > array[j]+1) { + temp = array[j]; + array[j] = array[j+1]; + arrat[j+1] = temp; + check=0; + } + } + if (check) { + // this can be removed if needed. it simple checks if the array is sorted yet or not! + break; + } + } +} Added: src/trunk/source/G3L_ENGINE/algorithms/g3l_heapsort.cpp =================================================================== --- src/trunk/source/G3L_ENGINE/algorithms/g3l_heapsort.cpp (rev 0) +++ src/trunk/source/G3L_ENGINE/algorithms/g3l_heapsort.cpp 2006-03-07 13:46:19 UTC (rev 35) @@ -0,0 +1,65 @@ +/* + * G3L - Generation Three Language + * The New Modern Programming Language + * + * http://www.G3L.net + * g3l...@li... + * + * This project is released under the terms of the GNU General Public Licence. + * You can Read the license here: http://www.gnu.org/licenses/gpl.html +/* + +/* + * Short Description + * + * @author Adam Livesley <ada...@gm...> + * @copyright Copyright (c) 2005 G3L Dev Team. + * @licence GPL + * @version 1.00.0a + * @category G3L_ENGINE + * @package G3L + * @todo none + * @date 07/03/06 + */ + +#include <G3L_ENGINE/algorithms/g3l_heapsort.h> + +/* + * Wow! A SuperSonic HeapSort method! Sorts from 0 as well! + */ + +G3L_Heapsort::Q3L_Heapsort(int array, unsigned int N) { + unsigned int n = N, i = n/2, parent, child; + int t; + + for (;;) { + if (i > 0) { + i--; + t = array[i]; + } else { + n--; + if (n == 0) { + return; + } + t = array[n]; + array[n] = array[0]; + } + + parent = i; + child = i*2 + 1; + + while (child < n) { + if (child + 1 < n && array[child + 1] > array[child]) { + child++; + } + if (array[child] > t) { + array[parent] = array[child]; + parent = child; + child = parent*2+1; + } else { + break; + } + } + array[parent] = t; + } +} Modified: src/trunk/source/G3L_ENGINE/algorithms/g3l_quicksort.cpp =================================================================== --- src/trunk/source/G3L_ENGINE/algorithms/g3l_quicksort.cpp 2006-03-07 00:12:23 UTC (rev 34) +++ src/trunk/source/G3L_ENGINE/algorithms/g3l_quicksort.cpp 2006-03-07 13:46:19 UTC (rev 35) @@ -24,8 +24,42 @@ #include <G3L_ENGINE/algorithms/g3l_quicksort.h> -G3L_Quicksort::G3L_Quicksort() -{ - // quick sort code +/* + * Well, I did the Quicksort but decide to change it as previous version was limited to integers! + * This version is hacked and wacked! Allowing any data type! + * This is my intended solution for C, should work in C++ though! + */ + +void G3L_Quicksort::G3L_Quicksort_Swap(void *x, void *y, size_t l) { + char a* = x, *b = y, c; + while (l --) { + c = a*; + *a++ = b*; + *b++ = c; + } } +void G3L_Quicksort::G3L_Quicksort_Sort(char *array, size_t size, int (*cmp)(void*,void*), int begin, int end) { + if (end > begin) { + void *pivot = array + begin; + int l = begin + size; + int r = end; + while (l < r) { + if (cmp(array+l,pivot) <= 0) { + l += size; + } else { + r -= size; + G3L_Quicksort::G3L_Quicksort_Swap(array+l, array+r, size); + } + } + l -= size; + G3L_Quicksort::G3L_Quicksort_Swap(array+begin, array+l, size); + G3L_Quicksort::G3L_Quicksort_Sort(array, size, cmp, begin, l); + G3L_Quicksort::G3L_Quicksort_Sort(array, size, cmp, r, end); + } +} + +G3L_Quicksort::Q3L_Quicksort(void *array, size_t nitems, size_t size, int (*cmp)(void*,void*)) { + G3L_Quicksort::G3L_Quicksort_Sort(array, size, cmp, 0, (nitems-1)*size); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |