本文整理汇总了C#中SparseArray.GetKeys方法的典型用法代码示例。如果您正苦于以下问题:C# SparseArray.GetKeys方法的具体用法?C# SparseArray.GetKeys怎么用?C# SparseArray.GetKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseArray
的用法示例。
在下文中一共展示了SparseArray.GetKeys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CorrectKeysWithInsertsWithSpaces
public void CorrectKeysWithInsertsWithSpaces()
{
var array = new SparseArray<string>();
for (int i = 0; i < 1000; i++)
{
if (i % 2 == 0)
array.SetValue(i, i.ToString());
}
int offset = 0;
foreach (int key in array.GetKeys())
{
Assert.AreEqual(offset, key);
offset += 2;
}
// Verify that we didn't switch to chunks even though we have
// sparsely set items.
Assert.AreEqual("Values=1280", array.ToString());
}
示例2: VerifyKeysInOrderFromReverseInserts
public void VerifyKeysInOrderFromReverseInserts()
{
var array = new SparseArray<string>();
for (int i = 1000; i > 0; i--)
{
array.SetValue(i, "");
}
int offset = 1;
foreach (int key in array.GetKeys())
{
Assert.AreEqual(offset++, key);
}
// Verify the allocations.
Assert.AreEqual("Chunks=32, ChunkCapacity=37", array.ToString());
}
示例3: VerifyKeysInOrderFromRandomInserts
public void VerifyKeysInOrderFromRandomInserts()
{
var array = new SparseArray<string>();
var random = new Random();
for (int i = 0; i < 1000; i++)
{
array.SetValue(random.Next(), "");
}
int lastKey = int.MinValue;
foreach (int key in array.GetKeys())
{
Assert.Greater(key, lastKey);
lastKey = key;
}
}