本文整理汇总了C#中Deque.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.Clear方法的具体用法?C# Deque.Clear怎么用?C# Deque.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deque
的用法示例。
在下文中一共展示了Deque.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearPUT
public void ClearPUT([PexAssumeUnderTest]int[] input)
{
Deque<int> actual = new Deque<int> (input);
actual.Clear();
PexAssert.AreEqual(0, actual.Count);
}
示例2: ClearTest
public void ClearTest()
{
Deque<int> actual = new Deque<int> { 12, 45, 321 };
actual.Clear();
Assert.AreEqual(0, actual.Count);
}
示例3: TestDeque
private static void TestDeque(Deque deque)
{
deque.Clear();
System.Diagnostics.Debug.Assert(deque.Count == 0);
PopulateDequePushFront(deque);
PopulateDequePushBack(deque);
TestPopFront(deque);
TestPopBack(deque);
TestContains(deque);
TestCopyTo(deque);
TestToArray(deque);
TestClone(deque);
TestEnumerator(deque);
}
示例4: TestDeque
public static void TestDeque(Deque<int> deque)
{
deque.Clear();
Debug.Assert(deque.Count == 0);
PopulateDequePushFront(deque);
PopulateDequePushBack(deque);
TestPopFront(deque);
TestPopBack(deque);
TestContains(deque);
TestCopyTo(deque);
TestToArray(deque);
TestClone(deque);
TestEnumerator(deque);
}
示例5: TestPopFront
private static void TestPopFront(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
int j;
for(int i = 0; i < ElementCount; i++)
{
j = (int)deque.PopFront();
Debug.Assert(j == i);
}
Debug.Assert(deque.Count == 0);
}
示例6: ClearExample
public void ClearExample()
{
var deque = new Deque<string>();
deque.EnqueueHead("cat");
deque.EnqueueHead("dog");
deque.EnqueueHead("canary");
// There should be 3 items in the deque.
Assert.AreEqual(3, deque.Count);
// Clear the deque
deque.Clear();
// The deque should be empty.
Assert.AreEqual(0, deque.Count);
// No cat here..
Assert.IsFalse(deque.Contains("cat"));
}
示例7: PopulateDequePushFront
private static void PopulateDequePushFront(Deque deque)
{
deque.Clear();
for(int i = 0; i < ElementCount; i++)
{
deque.PushFront(i);
}
System.Diagnostics.Debug.Assert(deque.Count == ElementCount);
int j = ElementCount - 1;
foreach(int i in deque)
{
System.Diagnostics.Debug.Assert(i == j);
j--;
}
}
示例8: PopulateDequePushBack
private static void PopulateDequePushBack(Deque deque)
{
deque.Clear();
for(int i = 0; i < ElementCount; i++)
{
deque.PushBack(i);
}
Debug.Assert(deque.Count == ElementCount);
int j = 0;
foreach(int i in deque)
{
Debug.Assert(i == j);
j++;
}
}
示例9: TestClone
private static void TestClone(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
Deque deque2 = (Deque)deque.Clone();
System.Diagnostics.Debug.Assert(deque.Count == deque2.Count);
IEnumerator d2 = deque2.GetEnumerator();
d2.MoveNext();
foreach(object obj in deque)
{
System.Diagnostics.Debug.Assert(obj.Equals(d2.Current));
d2.MoveNext();
}
}
示例10: TestClone
private static void TestClone(Deque<int> deque)
{
deque.Clear();
PopulateDequePushBack(deque);
Deque<int> deque2 = (Deque<int>)deque.Clone();
Debug.Assert(deque.Count == deque2.Count);
IEnumerator<int> d2 = deque2.GetEnumerator();
d2.MoveNext();
foreach(int item in deque)
{
Debug.Assert(item.Equals(d2.Current));
d2.MoveNext();
}
}
示例11: IsEmptyExample
public void IsEmptyExample()
{
var deque = new Deque<string>();
// Deque will be empty initially
Assert.IsTrue(deque.IsEmpty);
deque.EnqueueHead("cat");
// Deque will be not be empty when an item is added
Assert.IsFalse(deque.IsEmpty);
deque.Clear();
// Deque will be empty when items are cleared
Assert.IsTrue(deque.IsEmpty);
}
示例12: TestContains
private static void TestContains(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
for(int i = 0; i < deque.Count; i++)
{
System.Diagnostics.Debug.Assert(deque.Contains(i));
}
System.Diagnostics.Debug.Assert(!deque.Contains(ElementCount));
}
示例13: TestToArray
private static void TestToArray(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
object[] array = deque.ToArray();
int i = 0;
foreach(object obj in deque)
{
System.Diagnostics.Debug.Assert(obj.Equals(array[i]));
i++;
}
}
示例14: TestPopBack
private static void TestPopBack(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
int j;
for(int i = 0; i < ElementCount; i++)
{
j = (int)deque.PopBack();
System.Diagnostics.Debug.Assert(j == ElementCount - 1 - i);
}
System.Diagnostics.Debug.Assert(deque.Count == 0);
}
示例15: TestEnumerator
private static void TestEnumerator(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
IEnumerator e = deque.GetEnumerator();
try
{
//object obj = e.Current;
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
foreach(object obj in deque)
{
System.Diagnostics.Debug.Assert(e.MoveNext());
}
System.Diagnostics.Debug.Assert(!e.MoveNext());
//object o = e.Current;
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
e.Reset();
foreach(object obj in deque)
{
System.Diagnostics.Debug.Assert(e.MoveNext());
}
System.Diagnostics.Debug.Assert(!e.MoveNext());
//object o = e.Current;
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
deque.PushBack(deque.Count);
e.Reset();
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
e.MoveNext();
UnityEngine.Debug.LogError("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}