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

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -