C# 中高性能搜索的最佳数据结构
我想知道哪种数据结构能为我的场景提供更好的性能...... 我的要求是: 可能有数百万条记录的巨大数据集,我只会写一次,并且在执行生命周期内不会再更改它,我不需要它以排序的方式存储...... 我本想使用 List 但如果我使用 Linq 查询并在 where 条件中调用 InRange 性能非常糟糕...如果我执行 foreach,性能不会那么好...我很确定有最好的方法(我正在考虑使用结构和/或实现 IEquatable 但性能没有提高...... 女巫是 C# 中查询速度最快且性能最佳的数据结构吗? 我想要的是一个数据结构来存储 Rnage 类的数百万个实例
class Range
{
public int Low {get; set;}
public int High {get; set;}
public bool InRange(int val) { return val >= Low && val <= High; }
}
一个逻辑示例是 List 但我担心 List 类没有针对我的要求进行优化...因为它已排序并且我不需要排序这对表演影响很大...
感谢您的帮助!
I was wondering which data structure would offer me better performance for my scenario....
My requirements are:
Possible Huge DataSet several million of records, I am going to write it only once and I am not going to change it any more during the execution lifetime, I don't need that it is stored in a sorted way....
I was thinking to go with List but if I use a Linq query and in the where condition call InRange performance are very bad... if I do a foreach, performance are not so great.... I am pretty sure that there is a best way to do it ( I was thinking to use a struct and or implement IEquatable but performance are not improving...
witch is the quickest data structure in C# for querying in my range with optimal performances?
What I want is a data structure to store several million of instances of the class Rnage
class Range
{
public int Low {get; set;}
public int High {get; set;}
public bool InRange(int val) { return val >= Low && val <= High; }
}
A logic example would be List but I am afraid that List class is not optimized for my requirements... since it is sorted and I don't need sorting and it affect a lot on performances...
thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你可能想要一棵区间树。 Stackoverflow 用户 alan2here 最近就他正在从事的项目提出了几个问题; Eric Lippert 向他指出了其中一个中的区间树结构。
I think you may want an interval tree. Stackoverflow user alan2here has recently asked several questions regarding a project he's working on; Eric Lippert pointed him towards the interval tree structure in one of them.