performance - How to subtract one huge list from another efficiently in C# -


i have long list of ids (integers) represents items in database:

var idlist = getallids(); 

i have huge generic list items add database:

list<t> itemstoadd; 

now, remove items generic list id in idlist. idlist simple array , subtract lists this:

itemstoadd.removeall(e => idlist.contains(e.id)); 

i pretty sure lot faster, datatypes should use both collections , efficient practice subtract them?

thank you!

transform temporarily idlist hashset<t> , use same method i.e.:

items.removeall(e => idlisthash.contains(e.id)); 

it should faster


Comments

Popular posts from this blog

python - Does anyone know how to configure the hunpos wrapper class on nltk? -

mysql - How to insert just year and month into date field? -