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]]]]] )
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.
#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.
#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.