java - How can I Subtract these lists faster? -


i want subtract 2 arraylists can have child not in other list.

i way:

removeids=(arraylist<integer>) storedids.clone(); removeids.removeall(downloadedids);  downloadids=(arraylist<integer>) downloadedids.clone(); downloadids.removeall(storedids); 

the problem both lists contain 5000childs , takes 4 seconds on androidphone.

is there fast way this? using sets faster?(i dont have duplicate values in lists)

i develop android app

use hashset instead of arraylist unless need keep order.

removing element requires scan of full list list implementations, hashset comparison calculation of hash code , identification of target bucket.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -