plugins/include/sorting.inc
changeset 535 f255342d132f
child 619 6934bf39171e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/sorting.inc	Mon Feb 26 08:21:09 2007 +0000
     1.3 @@ -0,0 +1,113 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * ===============================================================
     1.7 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 + * ===============================================================
     1.9 + *
    1.10 + *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
    1.11 + * or modified under the Terms and Conditions of its License Agreement, which is found 
    1.12 + * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    1.13 + * may change at any time.  To view the latest information, see:
    1.14 + *   http://www.sourcemod.net/license.php
    1.15 + *
    1.16 + * Version: $Id$
    1.17 + */
    1.18 +
    1.19 +
    1.20 +#if defined _sorting_included
    1.21 +  #endinput
    1.22 +#endif
    1.23 +#define _sorting_included
    1.24 +
    1.25 +/**
    1.26 + * @brief Contains sorting orders.
    1.27 + */
    1.28 +enum SortOrder
    1.29 +{
    1.30 +	Sort_Ascending = 0,		/**< Ascending order */
    1.31 +	Sort_Descending = 1,	/**< Descending order */
    1.32 +};
    1.33 +
    1.34 +/**
    1.35 + * Sorts an array of integers.
    1.36 + *
    1.37 + * @param array			Array of integers to sort in-place.
    1.38 + * @param array_size	Size of the array.
    1.39 + * @param order			Sorting order to use.
    1.40 + * @noreturn
    1.41 + */
    1.42 +native SortIntegers(array[], array_size, SortOrder:order = Sort_Ascending);
    1.43 +
    1.44 +/**
    1.45 + * Sorts an array of float point numbers.
    1.46 + *
    1.47 + * @param array			Array of floating point numbers to sort in-place.
    1.48 + * @param array_size	Size of the array.
    1.49 + * @param order			Sorting order to use.
    1.50 + * @noreturn
    1.51 + */
    1.52 +native SortFloats(Float:array[], array_size, SortOrder:order = Sort_Ascending);
    1.53 +
    1.54 +/**
    1.55 + * Sorts an array of strings.
    1.56 + *
    1.57 + * @param array			Array of strings to sort in-place.
    1.58 + * @param array_size	Size of the array.
    1.59 + * @param order			Sorting order to use.
    1.60 + * @noreturn
    1.61 + */
    1.62 +native SortStrings(String:array[][], num_strings, SortOrder:order = Sort_Ascending);
    1.63 +
    1.64 +/**
    1.65 + * Sort comparison function for 1D array elements.
    1.66 + * @note You may need to use explicit tags in order to use data properly.
    1.67 + *
    1.68 + * @param elem1			First element to compare.
    1.69 + * @param elem2			Second element to compare.
    1.70 + * @param array			Array that is being sorted (order is undefined).
    1.71 + * @param hndl			Handle optionally passed in while sorting.
    1.72 + * @return				-1 if first should go before second
    1.73 + *						0 if first is equal to second
    1.74 + *						1 if first should go after second
    1.75 + */
    1.76 +functag SortFunc1D public(elem1, elem2, const array[], Handle:hndl);
    1.77 +
    1.78 +/** 
    1.79 + * Sorts a custom 1D array.  You must pass in a comparison function.
    1.80 + *
    1.81 + * @param array			Array to sort.
    1.82 + * @param array_size	Size of the array to sort.
    1.83 + * @param sortfunc		Sort function.
    1.84 + * @param hndl			Optional Handle to pass through the comparison calls.
    1.85 + * @noreturn
    1.86 + */
    1.87 +native SortCustom1D(array[], array_size, SortFunc1D:sortfunc, Handle:hndl=INVALID_HANDLE);
    1.88 +
    1.89 +/**
    1.90 + * Sort comparison function for 2D array elements (sub-arrays).
    1.91 + * @note You may need to use explicit tags in order to use data properly.
    1.92 + *
    1.93 + * @param elem1			First array to compare.
    1.94 + * @param elem2			Second array to compare.
    1.95 + * @param array			Array that is being sorted (order is undefined).
    1.96 + * @param hndl			Handle optionally passed in while sorting.
    1.97 + * @return				-1 if first should go before second
    1.98 + *						0 if first is equal to second
    1.99 + *						1 if first should go after second
   1.100 + */
   1.101 +funcenum SortFunc2D
   1.102 +{
   1.103 +	public(array[], array[], const array[][], Handle:hndl),
   1.104 +	public(String:array[], String:array[], const String:array[][], Handle:hndl),
   1.105 +};
   1.106 +
   1.107 +/** 
   1.108 + * Sorts a custom 2D array.  You must pass in a comparison function.
   1.109 + *
   1.110 + * @param array			Array to sort.
   1.111 + * @param array_size	Size of the major array to sort (first index, outermost).
   1.112 + * @param sortfunc		Sort comparison function to use.
   1.113 + * @param hndl			Optional Handle to pass through the comparison calls.
   1.114 + * @noreturn
   1.115 + */
   1.116 +native SortCustom2D(array[][], array_size, SortFunc2D:sortfunc, Handle:hndl=INVALID_HANDLE);
   1.117 \ No newline at end of file