简体   繁体   English

在C#中以最快的速度搜索100,000个元素的列表

[英]Searching through a list of 100,000 elements as fast as possible in C#

I will soon have the need to repeatedly search through a list (about every 15s) of about 100,000 elements as fast as possible using C# looking for elements that have specific values. 我很快将需要使用C#查找具有特定值的元素,以便尽可能快地反复搜索大约100,000个元素的列表(大约每15s)。 Would searching a List with Linq for elements (where 3-4 fields have specific values) be faster than using for example, an in-memory SQLite database? 使用Linq在List中搜索元素(其中3-4个字段具有特定值)会比使用内存中的SQLite数据库更快吗? Is there a better option available? 有更好的选择吗?

I wouldn't mind recreating the database upon every program execution, so reading data in from a CSV file would be acceptable. 我不介意在每次执行程序时都重新创建数据库,因此从CSV文件读取数据是可以接受的。

The dataset will be a window from a stream of data, subsequently, the list will gradually change, with one record being removed from the start of the list, and one more added to the end every 15s. 数据集将是数据流中的一个窗口,随后,列表将逐渐更改,从列表的开头删除一条记录,然后每隔15秒将另一条记录添加到末尾。

What options do I have? 我有什么选择?

You can use a helper library named IndexedList, you can download it from http://indexedlist.codeplex.com/ With this library you can add indexes on any field(s) of your object then perform fast searches in your list. 您可以使用名为IndexedList的帮助程序库,也可以从http://indexedlist.codeplex.com/下载该程序库。使用该库,您可以在对象的任何字段上添加索引,然后在列表中执行快速搜索。 Default index implementation uses Dictionary for storing index data, you can change it too. 默认索引实现使用字典来存储索引数据,您也可以更改它。 I have created this library for my own projects then i published that as an open source project newly. 我已经为自己的项目创建了这个库,然后我将其作为一个开源项目新发布了。 I will be happy to hear your feedback about this library. 我很高兴听到您对这个图书馆的反馈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过 c# 从 1400 万个表中删除 100,000 个特定行? - How can I delete 100,000 specific rows from a table of 14 million via c#? 从WPF DataGrid导出超过100,000行到Excel-C#Microsoft.Office Interop 14 - Export more than 100,000 rows from wpf datagrid to Excel - C# Microsoft.Office Interop 14 立即管理和搜索100,000多个对象的有效方法? (C#) - Effective Method to Manage and Search Through 100,000+ Objects Instantly? (C#) 在sql表中通过100,000条记录进行通配符搜索的最佳优化技术是什么? - What is the best optimization technique for a wildcard search through 100,000 records in sql table C#搜索大单词列表 - C# Searching Through a Large Word List 将Webclient与Foreach Loop一起使用可下载约100,000个网页 - Using Webclient with Foreach Loop to Download Webpages About 100,000 使用.NET创建100,000个TCP连接 - Creating 100,000 tcp connections using .NET 每天处理超过100,000张上传图片的大小 - Handling resizing over 100,000 uploaded images per day 在单台计算机上测试100,000个并发用户 - Testing for 100,000 concurrent users on a single machine C# 搜索一个列表并将信息发送到另一个列表 - C# Searching through one list and sending information to another list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM