
怎么样:
var intersection = listOfLists .Skip(1) .Aggregate( new HashSet<T>(listOfLists.First()), (h, e) => { h.IntersectWith(e); return h; } );这样,就可以通过始终使用同一HashSet并在单个语句中对其进行优化。只要确保listOfLists始终包含至少一个列表即可。
欢迎分享,转载请注明来源:内存溢出

怎么样:
var intersection = listOfLists .Skip(1) .Aggregate( new HashSet<T>(listOfLists.First()), (h, e) => { h.IntersectWith(e); return h; } );这样,就可以通过始终使用同一HashSet并在单个语句中对其进行优化。只要确保listOfLists始终包含至少一个列表即可。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)