本文整理汇总了C#中SparseArray.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SparseArray.ToString方法的具体用法?C# SparseArray.ToString怎么用?C# SparseArray.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseArray
的用法示例。
在下文中一共展示了SparseArray.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GettingNonExistingReturnsNull
public void GettingNonExistingReturnsNull()
{
var array = new SparseArray<string>();
Assert.IsNull(array.GetValue(10000));
// We shouldn't have allocated items.
Assert.AreEqual("Values=20", array.ToString());
}
示例2: GetNegativeShouldNotFail
public void GetNegativeShouldNotFail()
{
var array = new SparseArray<string>();
Assert.IsNull(array.GetValue(-10));
// We shouldn't have allocated items.
Assert.AreEqual("Values=20", array.ToString());
}
示例3: 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());
}
示例4: InsertWithSpaces
public void InsertWithSpaces()
{
var array = new SparseArray<string>();
for (int i = 0; i < 1000; i++)
{
if (i % 2 == 0)
array.SetValue(i, i.ToString());
}
for (int i = 0; i < 1000; i++)
{
if (i % 2 == 0)
{
Assert.AreEqual(i.ToString(), array.GetValue(i));
}
else
{
Assert.IsNull(array.GetValue(i));
}
}
// Verify that we didn't switch to chunks even though we have
// sparsely set items.
Assert.AreEqual("Values=1280", array.ToString());
}
示例5: InsertAtHighIndex
public void InsertAtHighIndex()
{
var array = new SparseArray<string>();
int offset = 1000000;
// Insert some items.
for (int i = 0; i < 1000; i++)
{
array.SetValue(offset + i, i.ToString());
}
// Verify that we can get them back.
for (int i = 0; i < 1000; i++)
{
Assert.AreEqual(i.ToString(), array.GetValue(offset + i));
}
// Verify that we've switched to chunks.
Assert.AreEqual("Chunks=33, ChunkCapacity=37", array.ToString());
}
示例6: 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());
}
示例7: SimpleInserts
public void SimpleInserts()
{
var array = new SparseArray<string>();
// Insert some items.
for (int i = 0; i < 1000; i++)
{
array.SetValue(i, i.ToString());
}
// Verify that we can get them back.
for (int i = 0; i < 1000; i++)
{
Assert.AreEqual(i.ToString(), array.GetValue(i));
}
// Verify that we didn't switch to chunks.
Assert.AreEqual("Values=1280", array.ToString());
}