.net - Compare two ArrayLists -


i trying compare 2 arraylists without success.

what have this:

dim array_1 new arraylist() dim array_2 new arraylist() dim final_array new arraylist() 

in array_1 , array_2 have:

array_1({10, 20}, {11, 25}, {12, 10}) array_2({10, 10}, {11, 20}) 

and in final_array want get:

array_1(1) - array_2(1) 

to this:

final_array({10, 10}, {11, 5}, {12, 10} 

how can create code correctly? here attempt:

for each element in array_1     each element_2 in array_2         if element(0) = element_2(0)             final_array.add({element(0), element(1) - element_2(1)})         else             final_array.add({element(0), element(1)})         end if     next next 

this code not want.

you should not join 2 arrays that. basically, each element in first array, iterate whole second array.

so, in pseudo-code (sorry, vb skills awful) should this:

let end = min(array1.lenght, array2.length) = 0 end   if array1[i].first = array2[i].first   final_array[i] = {array1[i].first, array1[i].second - array2[i].second}   else final_array[i] = array1[i]  // in case array1 bigger array2 need copy last elements j = array1.length   final_array[j] = array1[j] 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -