Hi everybody
I search for most efficient way to get de index of a value in array
Base on (conditionnal) that value is in the second array
i.e.:
array1 (1,3,4,6,7,9,12,23,34,45,99…) << 1000 value in array >>
array2 (10,11,23,56,90,100…) << 1000 value in array >>
i want to get the index of value for the matching 23 in the array1
…
I thought a loop through the second array inside a loop through the first is surely overkill
Is ( IndexOf ) would be better ( i don’t know the mechanism behind that function )
Thanks
for each v as integer in array2
dim pos as integer = array1.IndexOf( v )
if pos <> -1 then
// The same value is in both arrays
end if
next
Depending on what you’re doing, you might be better off using Dictionary rather than arrays.
So the ( IndexOf ) is the right way !!
Actually a convert my dictionary to array ( i never thought to use dictionary as permanent data container )
Im using dictionary to remove double value only
I need to add, remove and sort data… can i make these change in dictionary
Thanks Kem
Here is a smal program to compare to arrays (no Dictionary !).
Very fast for large Arrays.
Thanks but i dont find it very small… to include in a project routine
It didn’t work on Xojo 2013 4.1
( Theres is no class with the name C1 )
You can initiate C1=StringArray as Type ??