本文整理汇总了C#中Deque.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.CopyTo方法的具体用法?C# Deque.CopyTo怎么用?C# Deque.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deque
的用法示例。
在下文中一共展示了Deque.CopyTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyConstructorPUT
public void CopyConstructorPUT(int[] input)
{
Deque<int> actual = new Deque<int>(input);
int[] output = new int[input.Length];
actual.CopyTo(output, 0);
CollectionAssert.AreEqual(input, output);
}
示例2: ExceptionNotEnoughSpaceFromIndex
public void ExceptionNotEnoughSpaceFromIndex()
{
var deque = new Deque<int>();
deque.EnqueueHead(5);
deque.EnqueueTail(3);
deque.EnqueueTail(2);
deque.EnqueueHead(55);
var array = new int[4];
deque.CopyTo(array, 1);
}
示例3: ExceptionArrayTooSmall
public void ExceptionArrayTooSmall()
{
var deque = new Deque<int>();
deque.EnqueueHead(5);
deque.EnqueueTail(3);
deque.EnqueueTail(2);
deque.EnqueueHead(55);
var array = new int[3];
deque.CopyTo(array, 0);
}
示例4: ExceptionInvalidArray2
public void ExceptionInvalidArray2()
{
var deque = new Deque<int>();
for (var i = 1; i < 20; i++)
{
deque.EnqueueHead(i);
}
var array = new int[18];
deque.CopyTo(array, 0);
}
示例5: CopyToExample
public void CopyToExample()
{
var deque = new Deque<string>();
deque.EnqueueHead("cat");
deque.EnqueueHead("dog");
deque.EnqueueHead("canary");
deque.EnqueueHead("canary");
// create new string array
// note that the count is 4 because "canary" will exists twice.
var stringArray = new string[4];
deque.CopyTo(stringArray, 0);
}
示例6: TestCopyTo
private static void TestCopyTo(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
int[] array = new int[deque.Count];
deque.CopyTo(array, 0);
foreach(int i in deque)
{
System.Diagnostics.Debug.Assert(array[i] == i);
}
array = new int[deque.Count * 2];
deque.CopyTo(array, deque.Count);
foreach(int i in deque)
{
System.Diagnostics.Debug.Assert(array[i + deque.Count] == i);
}
array = new int[deque.Count];
try
{
deque.CopyTo(null, deque.Count);
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
deque.CopyTo(array, -1);
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
deque.CopyTo(array, deque.Count / 2);
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
deque.CopyTo(array, deque.Count);
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
deque.CopyTo(new int[10, 10], deque.Count);
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
示例7: Simple
public void Simple()
{
var dequeeque = new Deque<int>();
for (var i = 1; i < 20; i++)
{
dequeeque.EnqueueHead(i);
}
var array = new int[19];
dequeeque.CopyTo(array, 0);
var counter = 1;
for (var i = 18; i > 0; i--)
{
Assert.AreEqual(array[i], counter);
counter++;
}
}
示例8: ExceptionNullArray
public void ExceptionNullArray()
{
var deque = new Deque<int>();
deque.CopyTo(null, 0);
}