plugins/include/sorting.inc
author David Anderson <dvander@alliedmods.net>
Mon Jun 18 03:39:15 2007 +0000 (2007-06-18)
changeset 977 1dd1a7659ad4
parent 634 85108309e453
child 1330 ab94316bb52b
permissions -rw-r--r--
fixed a bug where menu handler used wrong variable for param2 bitmask in MenuVoteEnd
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 
    17 #if defined _sorting_included
    18   #endinput
    19 #endif
    20 #define _sorting_included
    21 
    22 /**
    23  * Contains sorting orders.
    24  */
    25 enum SortOrder
    26 {
    27 	Sort_Ascending = 0,		/**< Ascending order */
    28 	Sort_Descending = 1,	/**< Descending order */
    29 };
    30 
    31 /**
    32  * Sorts an array of integers.
    33  *
    34  * @param array			Array of integers to sort in-place.
    35  * @param array_size	Size of the array.
    36  * @param order			Sorting order to use.
    37  * @noreturn
    38  */
    39 native SortIntegers(array[], array_size, SortOrder:order = Sort_Ascending);
    40 
    41 /**
    42  * Sorts an array of float point numbers.
    43  *
    44  * @param array			Array of floating point numbers to sort in-place.
    45  * @param array_size	Size of the array.
    46  * @param order			Sorting order to use.
    47  * @noreturn
    48  */
    49 native SortFloats(Float:array[], array_size, SortOrder:order = Sort_Ascending);
    50 
    51 /**
    52  * Sorts an array of strings.
    53  *
    54  * @param array			Array of strings to sort in-place.
    55  * @param array_size	Size of the array.
    56  * @param order			Sorting order to use.
    57  * @noreturn
    58  */
    59 native SortStrings(String:array[][], num_strings, SortOrder:order = Sort_Ascending);
    60 
    61 /**
    62  * Sort comparison function for 1D array elements.
    63  * @note You may need to use explicit tags in order to use data properly.
    64  *
    65  * @param elem1			First element to compare.
    66  * @param elem2			Second element to compare.
    67  * @param array			Array that is being sorted (order is undefined).
    68  * @param hndl			Handle optionally passed in while sorting.
    69  * @return				-1 if first should go before second
    70  *						0 if first is equal to second
    71  *						1 if first should go after second
    72  */
    73 functag SortFunc1D public(elem1, elem2, const array[], Handle:hndl);
    74 
    75 /** 
    76  * Sorts a custom 1D array.  You must pass in a comparison function.
    77  *
    78  * @param array			Array to sort.
    79  * @param array_size	Size of the array to sort.
    80  * @param sortfunc		Sort function.
    81  * @param hndl			Optional Handle to pass through the comparison calls.
    82  * @noreturn
    83  */
    84 native SortCustom1D(array[], array_size, SortFunc1D:sortfunc, Handle:hndl=INVALID_HANDLE);
    85 
    86 /**
    87  * Sort comparison function for 2D array elements (sub-arrays).
    88  * @note You may need to use explicit tags in order to use data properly.
    89  *
    90  * @param elem1			First array to compare.
    91  * @param elem2			Second array to compare.
    92  * @param array			Array that is being sorted (order is undefined).
    93  * @param hndl			Handle optionally passed in while sorting.
    94  * @return				-1 if first should go before second
    95  *						0 if first is equal to second
    96  *						1 if first should go after second
    97  */
    98 funcenum SortFunc2D
    99 {
   100 	public(array[], array[], const array[][], Handle:hndl),
   101 	public(String:array[], String:array[], const String:array[][], Handle:hndl),
   102 };
   103 
   104 /** 
   105  * Sorts a custom 2D array.  You must pass in a comparison function.
   106  *
   107  * @param array			Array to sort.
   108  * @param array_size	Size of the major array to sort (first index, outermost).
   109  * @param sortfunc		Sort comparison function to use.
   110  * @param hndl			Optional Handle to pass through the comparison calls.
   111  * @noreturn
   112  */
   113 native SortCustom2D(array[][], array_size, SortFunc2D:sortfunc, Handle:hndl=INVALID_HANDLE);