Tag: lookup

如何ToLookup()与多个索引?

考虑下面的C#Console应用程序的代码,使用 如何修改它以替换该行: foreach (Product product in productsByCategory[category]) 通过代码行 foreach (Product product in productsByCategory[category][Id]) ? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace myQuestion { class Program { static void Main(string[] args) { var products = new List { new Product { Id = 1, Category = “Garden”, Value = 15.0 }, new Product { […]

遍历后加快数组查找速度?

我有一个123MB的大型int数组,它基本上是这样使用的: private static int[] data = new int[32487834]; static int eval(int[] c) { int p = data[c[0]]; p = data[p + c[1]]; p = data[p + c[2]]; p = data[p + c[3]]; p = data[p + c[4]]; p = data[p + c[5]]; return data[p + c[6]]; } eval()用不同的c调用很多(~50B次),我想知道是否(以及如何)我可以加速它。 我已经使用了一个不安全的函数和一个使用所有CPU 的固定数组 。 它是RayW的TwoPlusTwo 7卡评估器的C#端口。 C ++版本的速度微不足道。 […]