plugins/include/adt_array.inc
changeset 1664 e054be79e28a
parent 1451 14d1cc64bd78
child 1683 63b830faea21
     1.1 --- a/plugins/include/adt_array.inc	Fri Nov 09 18:08:09 2007 +0000
     1.2 +++ b/plugins/include/adt_array.inc	Fri Nov 09 23:46:05 2007 +0000
     1.3 @@ -80,6 +80,17 @@
     1.4  native ClearArray(Handle:array);
     1.5  
     1.6  /**
     1.7 + * Clones an array, returning a new handle with the same size and data. This should NOT
     1.8 + * be confused with CloneHandle. This is a completely new handle with the same data but
     1.9 + * no relation to the original. You MUST close it.
    1.10 + *
    1.11 + * @param array			Array handle to be cloned
    1.12 + * @return			New handle to the cloned array object
    1.13 + * @error			Invalid Handle
    1.14 + */
    1.15 + native Handle:CloneArray(Handle:array);
    1.16 +
    1.17 +/**
    1.18   * Resizes an array.  If the size is smaller than the current size,
    1.19   * the array is truncated.
    1.20   *
    1.21 @@ -250,25 +261,33 @@
    1.22  native SwapArrayItems(Handle:array, index1, index2);
    1.23  
    1.24  /**
    1.25 - * Returns true is the supplied string exists within the supplied array.
    1.26 + * Returns the index for the first occurance of the provided string. If the string
    1.27 + * cannot be located, -1 will be returned.
    1.28   *
    1.29   * @param array			Array Handle.
    1.30   * @param item			String to search for
    1.31 - * @return			True if found, false if not
    1.32 - * @error			Invalid handle
    1.33 + * @return			Array index, or -1 on failure
    1.34 + * @error			Invalid Handle
    1.35   */
    1.36 +native FindStringInArray(Handle:array, const String:item[]);
    1.37 + 
    1.38 +/**
    1.39 + * Returns the index for the first occurance of the provided value. If the value
    1.40 + * cannot be located, -1 will be returned.
    1.41 + *
    1.42 + * @param array			Array Handle.
    1.43 + * @param item			Value to search for
    1.44 + * @return			Array index, or -1 on failure
    1.45 + * @error			Invalid Handle
    1.46 + */
    1.47 +native FindValueInArray(Handle:array, item); 
    1.48 +
    1.49 +/**
    1.50 + * Backwards compatible stock - Use FindStringInArray()
    1.51 + * @deprecated		Replaced by FindStringInArray()
    1.52 + */
    1.53 +#pragma deprecated Use FindStringInArray() instead
    1.54  stock bool:IsStringInArray(Handle:array, const String:item[])
    1.55  {
    1.56 -	decl String:curItem[64];
    1.57 -	
    1.58 -	for (new i = 0; i < GetArraySize(array); i++)
    1.59 -	{
    1.60 -		GetArrayString(array, i, curItem, sizeof(curItem));
    1.61 -		if(strcmp(item, curItem, false) == 0)
    1.62 -		{
    1.63 -			return true;
    1.64 -		}		
    1.65 -	}
    1.66 -
    1.67 -	return false;
    1.68 -}
    1.69 +	return (FindStringInArray(array, item) != -1);
    1.70 +}
    1.71 \ No newline at end of file