本文整理汇总了C#中Stack.AsEnumerable方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.AsEnumerable方法的具体用法?C# Stack.AsEnumerable怎么用?C# Stack.AsEnumerable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack.AsEnumerable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Accept
public bool Accept(IVisitor visitor, Stack<int> stack)
{
Stack<int> inStack = new Stack<int>();
// Reverse the stack
Stack<int> resumeStack = new Stack<int>(stack.AsEnumerable());
bool result = Accept(visitor, inStack, resumeStack);
stack.Clear();
foreach (int i in inStack) {
stack.Push(i);
}
return result;
}
示例2: tracePath
private IEnumerable<Point> tracePath(Node lastNode)
{
var path = new Stack<Point>();
path.Push(lastNode.Location);
while (lastNode.Parent != null)
{
lastNode = lastNode.Parent;
path.Push(lastNode.Location);
}
return path.AsEnumerable();
}
示例3: CallByName
private void CallByName(ICommandContext context)
{
// It has to look up the availabe function names
Function function = null;
if (parametersCount >= 0)
{
function = context.FunctionLookup.GetFunctionByNameAndParameterCount(functionName, parametersCount);
if (function == null)
{
throw new PsimulexCoreException(string.Format("Call to an undefined function: {0} with {1} parameters.", functionName, parametersCount));
}
}
else
{
function = context.FunctionLookup.GetFunctionByName(functionName);
if (function == null)
{
throw new PsimulexCoreException("Call to an undefined function: " + functionName);
}
}
if (function.IsUserDefined)
{
UserDefinedFunction udf = function as UserDefinedFunction;
Stack<BaseType> parameters = new Stack<BaseType>();
foreach (var param in udf.Parameters)
{
var value = context.RunStack.Pop();
if (param.IsReference)
{
value = value.ToReference();
}
parameters.Push(value.Clone());
}
parameters = parameters.Reverse();
context.PushState();
foreach (var param in udf.Parameters)
{
context.AddVariable(param.Name, parameters[udf.Parameters.IndexOf(param)]);
}
// Just jump to its entry point.
context.PC = udf.EntryPoint;
}
else
{
// Pack each parameter, and Invoke.
Stack<BaseType> poppedValues = new Stack<BaseType>();
var parameters = new List<BaseType>(function.ParameterCount);
for (int i = 0; i < function.ParameterCount; ++i)
{
var param = context.RunStack.Pop();
if (function.Parameters[i].IsReference)
{
param = param.ToReference();
}
poppedValues.Push(param.Clone());
}
parameters.AddRange(poppedValues.AsEnumerable());
// Make the call
var returnValue = context.System.SystemCall(function, parameters);
// Push the returned value
if (function.HasReturnValue)
{
context.RunStack.Push(returnValue);
}
foreach (var param in parameters)
{
param.Delete();
}
}
}