# Function Reference

# _ArrayUnique

Returns the Elements from a column of a 1D or 2D array, removing all duplicates

#include <Array.au3>
_ArrayUnique ( Const ByRef $aArray [, $iColumn = 0 [, $iBase = 0 [, $iCase = 0 [, $iCount = $ARRAYUNIQUE_COUNT [, $iIntType = $ARRAYUNIQUE_AUTO]]]]] )

## Parameters

$aArray | The Array to use
$iColumn | [optional] 0-based column to be used - default 0. (2D only)
$iBase | [optional] The array is 0-based or 1-based. Default 0 : 0-based.
$iCase | [optional] Flag to indicate if the operations should be case sensitive. Default 0 : not case sensitive.
$iCount | [optional] Flag to determine if [0] element holds the count of returned items (default) - see Remarks for details.
$iIntType | [optional] Flag to change function algorithm - see Remarks for details.

## Return Value

Success: | a 1-dimensional array containing only the unique elements of that Column.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array or has no elements to check. 2 - $aArray is not a 1D or 2D array 3 - Invalid $iBase or $iCase value 4 - Invalid $iCount value 5 - Invalid $iIntType value 6 - $iColumn ouside array bounds 7 - Mismatch of Int32 and Int64 items - requires $iIntType to be set

## Remarks

Returns an array containing the unique elements.
By default $iCount is set to $ARRAYUNIQUE_COUNT (1) and a count is placed in the [0] element. Setting $iCount to $ARRAYUNIQUE_NOCOUNT (0) returns a list without a count.
The function can use a fast algorithm as long as the elements to be examined do not contain Int64 values (e.g. 64 bit integers, handles, pointers) - if these values are present then the function must use a slower algorithm. Setting the $iIntType parameter alters function behaviour as follows:
$ARRAYUNIQUE_AUTO (0) (Default) : If first element not an integer runs fast algorithm - returns error if Int64 elements are found.
: If first element is integer sets relevant FORCE32/64 value.
$ARRAYUNIQUE_FORCE32 (1) : Forces all integers to Int32, runs fast algorithm - returns error if Int64 values are found.
$ARRAYUNIQUE_FORCE64 (2) : Forces all integers to Int64, runs slow algorithm - returns error if Int32 values are found.
$ARRAYUNIQUE_MATCH (3) : 0x00000123 and 0x0123 considered the same value, only first encountered returned - runs slow algorithm.
$ARRAYUNIQUE_DISTINCT (4) : 0x00000123 and 0x0123 considered as distinct, both returned - runs slow algorithm.
Using other than the default $ARRAYUNIQUE_AUTO setting is only required it is known or suspected that Int64 values will be examined. The requirement to use a slower algorithm when dealing with Int64 values is a limitation of the Scripting.Dictionary object used within the function, not of AutoIt itself.

## Related

_ArrayMax, _ArrayMin

## Example

### Example 1

    #include <Array.au3>

    Local $aArray[10] = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] ; Create a 1-dimensional array that contains duplicate values.
    _ArrayDisplay($aArray, "$aArray Initial") ; Display the current array.

    Local $aArrayUnique = _ArrayUnique($aArray) ; Use default parameters to create a unique array.
    _ArrayDisplay($aArrayUnique, "$aArray Unique") ; Display the unique array.

### Example 2

    #include <Array.au3>

    Local $aArray[6][2] = [[1, "A"], [2, "B"], [3, "C"], [1, "A"], [2, "B"], [3, "C"]]
    _ArrayDisplay($aArray, "2D array") ; Display the current array.
    Local $aArrayUnique = _ArrayUnique($aArray) ; Use default parameters to create a unique array of the first column.
    _ArrayDisplay($aArrayUnique, "$aArray first column") ; Display the unique array.

    $aArrayUnique = _ArrayUnique($aArray, 1) ; Create a unique array of the second column.
    _ArrayDisplay($aArrayUnique, "$aArray second column") ; Display the unique array.