本文整理汇总了C#中Trie.HasPositionalSearch方法的典型用法代码示例。如果您正苦于以下问题:C# Trie.HasPositionalSearch方法的具体用法?C# Trie.HasPositionalSearch怎么用?C# Trie.HasPositionalSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trie
的用法示例。
在下文中一共展示了Trie.HasPositionalSearch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public static void Test()
{
var testcase = StringSearchTestCase.New(50, 10, 100000);
Stopwatch stopWatch = new Stopwatch();
//searcher
StringSearcher searcher = new StringSearcher();
stopWatch.Start();
testcase.TestDictionary.WithEach(x =>
{
searcher.Add(x, x);
});
stopWatch.Stop();
Debug.WriteLine("searcher init elapsed ms {0}", stopWatch.ElapsedMilliseconds);
stopWatch.Reset();
stopWatch.Start();
var searchermatches = searcher.FindMatches(testcase.TestSearchText);
stopWatch.Stop();
Debug.WriteLine("searcher elapsed ms {0}", stopWatch.ElapsedMilliseconds);
Debug.WriteLine(
string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, searchermatches.Count())
);
stopWatch.Reset();
stopWatch.Start();
//trie
Trie trie = new Trie();
testcase.TestDictionary.WithEach(x =>
{
trie.Add(x, x);
});
stopWatch.Stop();
Debug.WriteLine("trie init elapsed ms {0}", stopWatch.ElapsedMilliseconds);
stopWatch.Reset();
stopWatch.Start();
var matches = trie.FindMatches(testcase.TestSearchText);
stopWatch.Stop();
Debug.WriteLine("forwardonly elapsed ms {0}", stopWatch.ElapsedMilliseconds);
Debug.WriteLine(
string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, matches.Count())
);
stopWatch.Reset();
stopWatch.Start();
var matches1b = TrieLogic.FindMatchesUsingForwardOnlyCursor2(trie, testcase.TestSearchText);
stopWatch.Stop();
Debug.WriteLine("forwardonly2 elapsed ms {0}", stopWatch.ElapsedMilliseconds);
Debug.WriteLine(
string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, matches1b.Count())
);
stopWatch.Reset();
stopWatch.Start();
var matches2 = trie.HasPositionalSearch().FindMatches(testcase.TestSearchText);
stopWatch.Stop();
Debug.WriteLine("seekahead elapsed ms {0}", stopWatch.ElapsedMilliseconds);
Debug.WriteLine(
string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, matches2.Count())
);
stopWatch.Reset();
stopWatch.Start();
var matches3 = trie.HasPositionalSearch().NonOverlapping().FindMatches(testcase.TestSearchText);
stopWatch.Stop();
Debug.WriteLine("seekaheadnonoverlapped elapsed ms {0}", stopWatch.ElapsedMilliseconds);
Debug.WriteLine(
string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, matches3.Count())
);
stopWatch.Reset();
stopWatch.Start();
var matches4 = trie.HasPositionalSearch().Paralleling().FindMatches(testcase.TestSearchText);
stopWatch.Stop();
Debug.WriteLine("seekaheadparallel elapsed ms {0}", stopWatch.ElapsedMilliseconds);
Debug.WriteLine(
string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, matches4.Count())
);
//stopWatch.Reset();
//stopWatch.Start();
//InlineTrie inline_trie = new InlineTrie();
//stopWatch.Start();
//testcase.TestDictionary.WithEach(x =>
//{
// inline_trie.Add(x, x);
//});
//stopWatch.Stop();
//Debug.WriteLine("inline init elapsed ms {0}", stopWatch.ElapsedMilliseconds);
//stopWatch.Reset();
//stopWatch.Start();
//var inline_matches = inline_trie.FindMatches(testcase.TestSearchText);
//stopWatch.Stop();
//Debug.WriteLine("inline elapsed ms {0}", stopWatch.ElapsedMilliseconds);
//Debug.WriteLine(
// string.Format("expected percent {0}. found {1}", testcase.ExpectedPercentMatch, inline_matches.Count)
// );
////trie
//.........这里部分代码省略.........