本文整理汇总了C#中Index.AddKey方法的典型用法代码示例。如果您正苦于以下问题:C# Index.AddKey方法的具体用法?C# Index.AddKey怎么用?C# Index.AddKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index.AddKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_get_sorted_elements_from_index
public void Can_get_sorted_elements_from_index()
{
var index = new Index<string>(new CharSet());
index.AddKey("4", "value4");
index.AddKey("5", "value5");
index.AddKey("1", "value1");
index.AddKey("2", "value2");
index.AddKey("3", "value3");
var lastKey = string.Empty;
foreach (var keyValuePair in index)
{
Assert.GreaterOrEqual(keyValuePair.Key, lastKey);
lastKey = keyValuePair.Key;
}
}
示例2: Can_add_element_to_index
public void Can_add_element_to_index()
{
var index = new Index<string>(new CharSet());
index.AddKey("lala", "value1");
index.AddKey("lala", "value2");
index.AddKey("pepe", "value3");
index.AddKey("la", "value4");
index.AddKey("lalala", "value5");
var values = index.GetValues("lala");
Assert.AreEqual(2, values.Count);
values = index.GetValues("pepe");
Assert.AreEqual(1, values.Count);
Assert.AreEqual("value3", values[0].Value);
values = index.GetValues("la");
Assert.AreEqual(1, values.Count);
Assert.AreEqual("value4", values[0].Value);
values = index.GetValues("lalala");
Assert.AreEqual(1, values.Count);
Assert.AreEqual("value5", values[0].Value);
}
示例3: Can_get_spanish_traditional_accent_insensitive_sorted_elements_from_index
public void Can_get_spanish_traditional_accent_insensitive_sorted_elements_from_index()
{
var index = new Index<string>(new CharSet(" .01234567890abcdefghijklmnñopqrstuvwxyz", '.', new System.Collections.Generic.Dictionary<char, char>
{
{'á', 'a'},
{'é', 'e'},
{'í', 'i'},
{'ó', 'o'},
{'ú', 'u'},
}
));
index.AddKey("01 o", "value5");
index.AddKey("01 u", "value2");
index.AddKey("01 í", "value4");
index.AddKey("01 i", "value4");
index.AddKey("01 a", "value3");
index.AddKey("01 e", "value1");
var values = index.GetAll();
Assert.AreEqual("01 í", values[2].Key);
}
示例4: Can_get_spanish_traditional_sorted_elements_from_index
public void Can_get_spanish_traditional_sorted_elements_from_index()
{
var index = new Index<string>(new CharSet(" .01234567890abcdefghijklmnñopqrstuvwxyz", '.'));
index.AddKey("01 OOO", "value3");
index.AddKey("01 ooo", "value1");
index.AddKey("01 ñ", "value1");
index.AddKey("01 a", "value4");
index.AddKey("01 n", "value5");
index.AddKey("01 Mama", "value2");
var values = index.GetAll();
Assert.AreEqual("01 ñ", values[3].Key);
Assert.AreEqual("01 OOO", values[4].Key);
Assert.AreEqual("01 ooo", values[5].Key);
}