# ****************
#
# Function generator for func_ra_sort module.
#
# Created by: Ferry Firmansjah (firmanf@itechnologist.com)
#
# More information: http://www.itechnologist.com/tech/func_ra.html
#
# Copyright (C) 2000 Ferry Firmansjah
# 
# This program 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 2
# of the License, or (at your option) any later version.
# 
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# ****************

func_cat = "func_ra_sort";
generator_add_category (func_cat);
generator_add_function ("array_bubblesort"
	, "Description: Sort an array using bubblesort.\n"
	& "    ** WARNING ** This sorting method is very inefficient for large arrays.\n"
	& "    Seriously consider using array_mergesort() or array_quicksort()\n"
	& "    instead.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         public ra2[] = {\"d\", \"z\", \"a\", \"y\"};\n"
	& "         array_bubblesort (ra1);\n"
	& "         array_bubblesort (ra2);\n"
	& "         -> ra1[] is now: {1, 4, 5, 5, 9}.\n"
	& "         -> ra2[] is now: {\"a\", \"d\", \"y\", \"z\"}.\n"
	& "Syntax:    array_bubblesort (inout inra[] [, in elementcount]););\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: inra[]: the array to sort\n"
	& "    elementcount: the number of elements in the array\n"
	& "        (can be obtained by array_length() function)"
	, 2
	, "inout inra "
	, "type_edit"
	, ""
	, "in elementcount"
	, "type_edit"
	, ""
);


generator_add_function ("array_bubblesort2"
	, "Description: Sort an array using bubblesort.\n"
	& "    The function allows sorting a subset of an array.\n"
	& "    ** WARNING ** This sorting method is very inefficient for large arrays.\n"
	& "    Seriously consider using array_mergesort() or array_quicksort()\n"
	& "    instead.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         public ra2[] = {\"d\", \"z\", \"a\", \"y\"};\n"
	& "         array_bubblesort (ra1);\n"
	& "         array_bubblesort (ra2);\n"
	& "         -> ra1[] is now: {1, 4, 5, 5, 9}.\n"
	& "         -> ra2[] is now: {\"a\", \"d\", \"y\", \"z\"}.\n"
	& "Syntax:    array_bubblesort2 (inout inra[] [, in startindex[, in endindex]]);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: inra[]: the array to sort\n"
	& "    startindex: the index of the first element to be sorted\n"
	& "    endindex: the index of the last element to be sorted\n"
	& "        (can be obtained by array_get_last_index() function)"
	, 3
	, "inout inra "
	, "type_edit"
	, ""
	, "in startindex"
	, "type_edit"
	, ""
	, "in endindex"
	, "type_edit"
	, ""
);


generator_add_function ("array_mergesort"
	, "Description: Sort an array using mergesort.\n"
	& "    ** NOTE **: This function requires the _array_mergesort() function.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         public ra2[] = {\"d\", \"z\", \"a\", \"y\"};\n"
	& "         array_mergesort (ra1);\n"
	& "         array_mergesort (ra2);\n"
	& "         -> ra1[] is now: {1, 4, 5, 5, 9}.\n"
	& "         -> ra2[] is now: {\"a\", \"d\", \"y\", \"z\"}.\n"
	& "Syntax:    array_mergesort (inout ra[] [, in elementcount]);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: ra[]: the array to sort\n"
	& "    elementcount: the number of elements in the array\n"
	& "        (can be obtained by array_length() function)"
	, 2
	, "inout ra "
	, "type_edit"
	, ""
	, "in elementcount"
	, "type_edit"
	, ""
);


generator_add_function ("array_mergesort2"
	, "Description: Sort an array or a subset of an array using mergesort.\n"
	& "    The function allows sorting a subset of an array.\n"
	& "    ** NOTE **: This function requires the _array_mergesort() function.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         public ra2[] = {\"d\", \"z\", \"a\", \"y\"};\n"
	& "         array_mergesort (ra1);\n"
	& "         array_mergesort (ra2);\n"
	& "         -> ra1[] is now: {1, 4, 5, 5, 9}.\n"
	& "         -> ra2[] is now: {\"a\", \"d\", \"y\", \"z\"}.\n"
	& "Syntax:    array_mergesort2 (inout ra[] [, in startindex[, endindex]]);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: ra[]: the array to sort.\n"
	& "    startindex: the first index of the element to be sorted in ra[].\n"
	& "    endindex: the last index of the element to be sorted in ra[]."
	, 3
	, "inout ra "
	, "type_edit"
	, ""
	, "in startindex"
	, "type_edit"
	, ""
	, "endindex"
	, "type_edit"
	, ""
);


generator_add_function ("_array_mergesort"
	, "Description: Underlying Implementation of the array_mergesort.\n"
	& "    This function requires an input and target array as parameters.\n"
	& "    ** NOTE ** Normally, this function is not called directly,\n"
	& "      use array_mergesort() instead.\n"
		& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
		& "         _array_mergesort (ra1, ra2, 5);\n"
		& "         -> ra1[] is unchanged: {5, 1, 4, 5, 9}.\n"
		& "         -> ra2[] is now: {1, 4, 5, 5, 9}.\n"
	& "Syntax:    _array_mergesort (inout origra[], out outra[], in n);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: origra[]: the original array containing unsorted elements\n"
	& "        (has to start at index 0)\n"
	& "    outra[]: the target array to store sorted elements into\n"
	& "    n: the number of elements in the array\n"
	& "        (can be obtained by array_length() function)"
	, 3
	, "inout origra"
	, "type_edit"
	, ""
	, "out outra"
	, "type_edit"
	, ""
	, "in n"
	, "type_edit"
	, ""
);


generator_add_function ("array_merge"
	, "Description: Merges the content of two sorted arrays into\n"
	& "    one array.\n"
	& "    ** NOTE ** This function is used by array_mergesort.\n"
	& "    E.g. public ra1[] = {1, 4, 7}; # sorted array\n"
	& "         public ra2[] = {4, 5, 7, 8}; # sorted array\n"
	& "         array_merge (ra1, ra2, ra3, 3, 4);\n"
	& "         -> ra1[] and ra2[] are unchanged.\n"
	& "         -> ra3[] is now: {1, 4, 4, 5, 7, 7, 8}.\n"
	& "Syntax:    array_merge (inout a[], inout b[], out c[], m, n);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: a[]: the first sorted array to merge\n"
	& "    b[]: the second sorted array to merge\n"
	& "    m: size of the first array (a[])\n"
	& "    n: size of the second array (b[])"
	, 5
	, "inout a"
	, "type_edit"
	, ""
	, "inout b"
	, "type_edit"
	, ""
	, "out c"
	, "type_edit"
	, ""
	, "m"
	, "type_edit"
	, ""
	, "n"
	, "type_edit"
	, ""
);


generator_add_function ("array_quicksort"
	, "Description: Sort an array using quicksort.\n"
	& "    ** NOTE **: This function requires the _array_mergesort() function.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         public ra2[] = {\"d\", \"z\", \"a\", \"y\"};\n"
	& "         array_quicksort (ra1);\n"
	& "         array_quicksort (ra2);\n"
	& "         -> ra1[] is now: {1, 4, 5, 5, 9}.\n"
	& "         -> ra2[] is now: {\"a\", \"d\", \"y\", \"z\"}.\n"
	& "Syntax:    array_quicksort (inout ra[] [, in elementcount]);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: ra[]: the array to sort\n"
	& "    elementcount: the number of elements in the array\n"
	& "        (can be obtained by array_length() function)"
	, 2
	, "inout ra "
	, "type_edit"
	, ""
	, "in elementcount"
	, "type_edit"
	, ""
);


generator_add_function ("array_quicksort2"
	, "Description: Sort an array or a portion of an array using quicksort.\n"
	& "    The function allows sorting a subset of an array.\n"
	& "    ** NOTE **: This function requires the _array_mergesort() function.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         public ra2[] = {\"d\", \"z\", \"a\", \"y\"};\n"
	& "         array_quicksort (ra1);\n"
	& "         array_quicksort (ra2);\n"
	& "         -> ra1[] is now: {1, 4, 5, 5, 9}.\n"
	& "         -> ra2[] is now: {\"a\", \"d\", \"y\", \"z\"}.\n"
	& "Syntax:    array_quicksort2 (inout ra[] [, in startindex[, endindex]]);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: ra[]: the array to sort\n"
	& "    startindex: the first index of the element to be sorted in ra[].\n"
	& "    endindex: the last index of the element to be sorted in ra[]."
	, 3
	, "inout ra "
	, "type_edit"
	, ""
	, "in startindex"
	, "type_edit"
	, ""
	, "endindex"
	, "type_edit"
	, ""
);


generator_add_function ("_array_quicksort"
	, "Description: Underlying Implementation of the array_quicksort.\n"
	& "    This function requires an input and target array as parameters.\n"
	& "    ** NOTE ** Normally, this function is not called directly,\n"
	& "      use array_quicksort() instead.\n"
	& "    E.g. public ra1[] = {5, 1, 4, 5, 9};\n"
	& "         _array_quicksort (ra1, ra2, 5);\n"
	& "         -> ra1[] is unchanged: {5, 1, 4, 5, 9}.\n"
	& "         -> ra2[] is now: {1, 4, 5, 5, 9}.\n"
	& "Syntax:    _array_quicksort (inout origra[], out outra[], in n);\n"
	& "Return values: E_OK for success.\n"
	& "Parameters: origra[]: the original array containing unsorted elements\n"
	& "        (has to start at index 0)\n"
	& "    outra[]: the target array to store sorted elements into\n"
	& "    n: the number of elements in the array\n"
	& "        (can be obtained by array_length() function)"
	, 3
	, "inout origra"
	, "type_edit"
	, ""
	, "out outra"
	, "type_edit"
	, ""
	, "in n"
	, "type_edit"
	, ""
);


generator_add_function_to_category (func_cat, "array_bubblesort");
generator_add_function_to_category (func_cat, "array_bubblesort2");
generator_add_function_to_category (func_cat, "array_mergesort");
generator_add_function_to_category (func_cat, "array_mergesort2");
generator_add_function_to_category (func_cat, "_array_mergesort");
generator_add_function_to_category (func_cat, "array_merge");
generator_add_function_to_category (func_cat, "array_quicksort");
generator_add_function_to_category (func_cat, "array_quicksort2");
generator_add_function_to_category (func_cat, "_array_quicksort");
