本文整理汇总了C#中Trie.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Trie.Get方法的具体用法?C# Trie.Get怎么用?C# Trie.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trie
的用法示例。
在下文中一共展示了Trie.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTest_Null
public void GetTest_Null()
{
Trie dictioanry = new Trie();
dictioanry.Add("a", 100);
var result = dictioanry.Get("b");
Assert.IsNull(result, "result must be null");
}
示例2: GetTest_UpperCase
public void GetTest_UpperCase()
{
Trie dictioanry = new Trie();
dictioanry.Add("a", 100);
var result = dictioanry.Get("A");
Assert.IsNotNull(result, "did not found word");
Assert.AreEqual(1, result.Count(), "Incorrect words count");
}
示例3: GetTest_Multiple
public void GetTest_Multiple()
{
Trie dictioanry = new Trie();
string[] input = new string[4] { "a", "ab", "abc", "bbc" };
dictioanry.Add(input[0], 100);
dictioanry.Add(input[1], 200);
dictioanry.Add(input[2], 300);
dictioanry.Add(input[3], 400);
var result = dictioanry.Get("a").ToList();
Assert.IsNotNull(result, "did not found word");
Assert.AreEqual(3, result.Count, "Incorrect words count");
for (int i = 0; i < result.Count; i++)
{
Assert.AreEqual(input[2 - i], result[i], "Incorrect word. " + i);
}
}
示例4: GetTest_TooLongWord
public void GetTest_TooLongWord()
{
Trie dictioanry = new Trie();
dictioanry.Get("veryverylongword");
}
示例5: GetTest_NullWord
public void GetTest_NullWord()
{
Trie dictioanry = new Trie();
dictioanry.Get(null);
}
示例6: Given__and__an__should_have_hierarchy_of_nodes__a_non_ending__n_ending__d_ending
public void Given__and__an__should_have_hierarchy_of_nodes__a_non_ending__n_ending__d_ending()
{
var trie = new Trie();
trie.Add("and");
trie.Add("an");
var aNode = trie.Get('a');
aNode.ShouldNotBeNull("a node is missing");
// ReSharper disable once PossibleNullReferenceException
aNode.IsEnding.ShouldBeFalse("a node should not be a ending");
aNode.Parent.ShouldBeNull("a node's parent should be null");
aNode.Value.ShouldBeNull("a node should not have a value");
var nNode = aNode.Get('n');
nNode.ShouldNotBeNull("n node is missing");
// ReSharper disable once PossibleNullReferenceException
nNode.IsEnding.ShouldBeTrue("n node should be a ending");
nNode.Parent.ShouldBeSameInstanceAs(aNode);
nNode.Value.ShouldBeEqualTo("an", "n should have a value 'an'");
var dNode = nNode.Get('d');
dNode.ShouldNotBeNull("d node is missing");
// ReSharper disable once PossibleNullReferenceException
dNode.IsEnding.ShouldBeTrue("d node should be a ending");
dNode.Parent.ShouldBeSameInstanceAs(nNode);
dNode.Value.ShouldBeEqualTo("and", "d should have a value 'and'");
}