本文整理汇总了C#中Deque.PushBack方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.PushBack方法的具体用法?C# Deque.PushBack怎么用?C# Deque.PushBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deque
的用法示例。
在下文中一共展示了Deque.PushBack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
private Deque<string> Create(params string[] elements)
{
var sut = new Deque<string>() { "_", "_", "_", "_" };
sut.PopFront();
sut.PopBack();
foreach(var element in elements)
{
sut.PushBack(element);
}
sut.PopFront();
sut.PopFront();
return sut;
}
示例2: PopulateDequePushBack
private static void PopulateDequePushBack(Deque deque)
{
deque.Clear();
for(int i = 0; i < ElementCount; i++)
{
deque.PushBack(i);
}
System.Diagnostics.Debug.Assert(deque.Count == ElementCount);
int j = 0;
foreach(int i in deque)
{
System.Diagnostics.Debug.Assert(i == j);
j++;
}
}
示例3: 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);
}
}
示例4: CreateNFA
private void CreateNFA(string input)
{
Stack<char> operatorStack = new Stack<char>();
var expandedInput = ConcatExpand(input);
for (int i = 0; i < expandedInput.Length; i++)
{
char c = expandedInput[i];
if (char.IsLetterOrDigit(c))
Push(c);
else if (operatorStack.Count == 0)
operatorStack.Push(c);
else if (c == '(')
operatorStack.Push(c);
else if (c == ')')
{
while (operatorStack.Peek() != '(')
{
var op = operatorStack.Pop();
if (op == (char)8)
Concat();
else if (op == '*')
Star();
else if (op == '|')
Union();
else
return;
}
operatorStack.Pop(); //pop up '('
}
else
{
while (operatorStack.Count != 0 && Presedece(c, operatorStack.Peek()))
{
var op = operatorStack.Pop();
if (op == (char)8)
Concat();
else if (op == '*')
Star();
else if (op == '|')
Union();
else
return;
}
operatorStack.Push(c);
}
}
while (operatorStack.Count > 0)
{
var op = operatorStack.Pop();
if (op == (char)8)
Concat();
else if (op == '*')
Star();
else if (op == '|')
Union();
else
return;
}
if (_operandStack.Count == 0)
return;
var A = _operandStack.Pop();
A.GetLastState().AcceptState = true;
#if DEBUG
if (A.GetFirstState() != null)
{
using (var stream = File.OpenWrite("NFA.txt"))
{
using (var sw = new StreamWriter(stream))
{
HashSet<int> processedStates = new HashSet<int>();
Deque<State> unprocessedStates = new Deque<State>();
unprocessedStates.PushBack(A.GetFirstState());
while(unprocessedStates.Count>0)
{
var state = unprocessedStates.PopFront();
var labels = state.GetLabels();
foreach (var label in labels)
{
var destinationStates = state.GetStates(label);
if (destinationStates != null)
{
foreach (var dest in destinationStates)
{
sw.WriteLine("Start:" + state.ToString() + "," + "End:" + dest.ToString() + "," + "Label:" + (label!=EPSILON? label.ToString():"EPSILON"));
if (!processedStates.Contains(dest.StateId))
{
unprocessedStates.PushBack(dest);
}
}
}
}
processedStates.Add(state.StateId);
}
}
}
}
//.........这里部分代码省略.........
示例5: TestEnumerator
private static void TestEnumerator(Deque deque)
{
deque.Clear();
PopulateDequePushBack(deque);
IEnumerator e = deque.GetEnumerator();
try
{
object obj = e.Current;
Debug.Fail("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
foreach(object obj in deque)
{
Debug.Assert(e.MoveNext());
}
Debug.Assert(!e.MoveNext());
object o = e.Current;
Debug.Fail("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
e.Reset();
foreach(object obj in deque)
{
Debug.Assert(e.MoveNext());
}
Debug.Assert(!e.MoveNext());
object o = e.Current;
Debug.Fail("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
deque.PushBack(deque.Count);
e.Reset();
Debug.Fail("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
e.MoveNext();
Debug.Fail("Exception failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}