我愿知道,如果我在一份文本中拥有一名官兵,那么检查某一方的扼杀是否恰当和正确的话是最好的方法。 我的字典中约有100 000个字,我只字要检查600个字。 我只是寻求最有效的方式。 我也应当首先储存所有雕像,然后处理它们。
Thanx
我愿知道,如果我在一份文本中拥有一名官兵,那么检查某一方的扼杀是否恰当和正确的话是最好的方法。 我的字典中约有100 000个字,我只字要检查600个字。 我只是寻求最有效的方式。 我也应当首先储存所有雕像,然后处理它们。
Thanx
100k 不是太多的,因此,你只能把所有东西放在
哈希姆的考察是关键的基础,因此会迅速缓解。
例如,这在法典中如何考虑:
string[] lines = File.ReadAllLines(@"C:MyDictionary.txt");
HashSet<string> myDictionary = new HashSet<string>();
foreach (string line in lines)
{
myDictionary.Add(line);
}
string word = "aadvark";
if (myDictionary.Contains(word))
{
Console.WriteLine("There is an aadvark");
}
else
{
Console.WriteLine("The aadvark is a lie");
}
或许应当使用HashSet<string>。 如果你重新使用。 NET 3.5或更高。
仅将有效字句装上HashSet<string>
,然后使用 每个候选人的
,或利用一些固定操作者找到所有有效字眼。
例如:
// There are loads of ways of loading words from a file, of course
var valid = new HashSet<string>(File.ReadAllLines("dictionary.txt"));
var candidates = new HashSet<string>(File.ReadAllLines("candidate.txt"));
var validCandidates = candidates.Intersect(valid);
var invalidCandidates = candidates.Except(valid);
您也不妨使用对个案敏感的比较或类似的比较——使用<条码>规范Comparer的静态特性,以在适当情况下取到<条码>。 StringComparer 可查阅<代码>HashSet的构造。
如果你重新使用。 NET 2, 您可使用。 Dictionary<string, whatever>
as a poor-man s set - basic use what each similar as the Value, and Justeck for keys.
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...