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
Post a Comment