Une petite aide pour optimiser du code serait la bienvenue.

Soit un tableau 2D avec :
- dans la première colonne, un numéro allant par exemple de 10000 à 99999
- dans la seconde colonne, les lettres A ou B
Il faut extraire de ce premier tableau, la liste de numéros ayant comme valeur dans la seconde colonne à la fois A et B.
Pour un tableau à 1 000 entrées c'est rapide, pour 10 000 un peu moins.

Il serait peut-être plus judicieux de créer un tableau avec un certain nombre de lignes et de redimensionner à la fin...
Voici le code pour que vous puissiez tester :
#include <Array.au3>
Global $g_aData[0][2]
Global $g_aExtract[0][2]
CreateData()
ExtractNumbersWithAllValues()
Func CreateData()
Local $bOtherValueCol2 = False
For $i = 1 To 10000
$bOtherValueCol2 = False
$sValueCol1 = Random(10000, 99999, 1)
For $j = 1 To Random(1, 3, 1)
_ArrayAdd($g_aData, $sValueCol1 & '|' & ($bOtherValueCol2 ? 'B' : 'A'))
If $bOtherValueCol2 = False And Random(1, 2, 1) = 2 Then $bOtherValueCol2 = True
If UBound($g_aData) = 10000 Then ExitLoop 2
Next
Next
_ArrayDisplay($g_aData, "Data")
EndFunc ;==>CreateData
Func ExtractNumbersWithAllValues()
Local $aValueA[0]
Local $iIndex = 0
Local $hTimer = TimerInit()
If $g_aData[0][1] = 'A' Then _ArrayAdd($aValueA, $g_aData[0][0])
For $iRow = 1 To UBound($g_aData) - 1
If Not (($g_aData[$iRow][0] = $g_aData[$iRow - 1][0]) And ($g_aData[$iRow][1] = $g_aData[$iRow - 1][1])) Then ; pas de vérif si valeurs col0 et col1 identiques à la previous row
$iIndex = _ArraySearch($aValueA, $g_aData[$iRow][0])
If $iIndex = -1 Then
If $g_aData[$iRow][1] = 'A' Then _ArrayAdd($aValueA, $g_aData[$iRow][0]) ; si numéro non présent dans table intermédiaire et valuer col1 = A
ElseIf $g_aData[$iRow][1] = 'B' Then ; recherche de la valeur A OK (implicite)
_ArrayAdd($g_aExtract, $g_aData[$iRow][0]) ; ajout dans le tableau définitif
EndIf
EndIf
Next
cwtimer($hTimer)
_ArrayDisplay(_ArrayUnique($g_aExtract, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT), "Extraction") ; suppression des doublons
EndFunc ;==>ExtractNumbersWithAllValues
Func cwtimer($hTimer)
Local $iTotalSec = Floor(TimerDiff($hTimer) / 1000)
Local $iMin = Floor($iTotalSec / 60)
Local $iSec = $iTotalSec - 60 * $iMin
If $iTotalSec < 10 Then
ConsoleWrite('Traitement effectué en ' & Floor(TimerDiff($hTimer)) & ' msec' & @CRLF)
Else
ConsoleWrite('Traitement effectué en ' & ($iMin > 0 ? $iMin & ' min ' : '') & $iSec & ' sec' & @CRLF)
EndIf
EndFunc ;==>cwtimer
Global $g_aData[0][2]
Global $g_aExtract[0][2]
CreateData()
ExtractNumbersWithAllValues()
Func CreateData()
Local $bOtherValueCol2 = False
For $i = 1 To 10000
$bOtherValueCol2 = False
$sValueCol1 = Random(10000, 99999, 1)
For $j = 1 To Random(1, 3, 1)
_ArrayAdd($g_aData, $sValueCol1 & '|' & ($bOtherValueCol2 ? 'B' : 'A'))
If $bOtherValueCol2 = False And Random(1, 2, 1) = 2 Then $bOtherValueCol2 = True
If UBound($g_aData) = 10000 Then ExitLoop 2
Next
Next
_ArrayDisplay($g_aData, "Data")
EndFunc ;==>CreateData
Func ExtractNumbersWithAllValues()
Local $aValueA[0]
Local $iIndex = 0
Local $hTimer = TimerInit()
If $g_aData[0][1] = 'A' Then _ArrayAdd($aValueA, $g_aData[0][0])
For $iRow = 1 To UBound($g_aData) - 1
If Not (($g_aData[$iRow][0] = $g_aData[$iRow - 1][0]) And ($g_aData[$iRow][1] = $g_aData[$iRow - 1][1])) Then ; pas de vérif si valeurs col0 et col1 identiques à la previous row
$iIndex = _ArraySearch($aValueA, $g_aData[$iRow][0])
If $iIndex = -1 Then
If $g_aData[$iRow][1] = 'A' Then _ArrayAdd($aValueA, $g_aData[$iRow][0]) ; si numéro non présent dans table intermédiaire et valuer col1 = A
ElseIf $g_aData[$iRow][1] = 'B' Then ; recherche de la valeur A OK (implicite)
_ArrayAdd($g_aExtract, $g_aData[$iRow][0]) ; ajout dans le tableau définitif
EndIf
EndIf
Next
cwtimer($hTimer)
_ArrayDisplay(_ArrayUnique($g_aExtract, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT), "Extraction") ; suppression des doublons
EndFunc ;==>ExtractNumbersWithAllValues
Func cwtimer($hTimer)
Local $iTotalSec = Floor(TimerDiff($hTimer) / 1000)
Local $iMin = Floor($iTotalSec / 60)
Local $iSec = $iTotalSec - 60 * $iMin
If $iTotalSec < 10 Then
ConsoleWrite('Traitement effectué en ' & Floor(TimerDiff($hTimer)) & ' msec' & @CRLF)
Else
ConsoleWrite('Traitement effectué en ' & ($iMin > 0 ? $iMin & ' min ' : '') & $iSec & ' sec' & @CRLF)
EndIf
EndFunc ;==>cwtimer