本文整理汇总了C#中Stack.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.RemoveAt方法的具体用法?C# Stack.RemoveAt怎么用?C# Stack.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack.RemoveAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestStackRemoveAt
public void TestStackRemoveAt()
{
Stack<int> stack = new Stack<int>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
Assert.AreEqual(2, stack.RemoveAt(1));
Assert.AreEqual(2, stack.Count);
Assert.AreEqual(3, stack.Pop());
Assert.AreEqual(1, stack.Pop());
}
示例2: ExecuteScript
//.........这里部分代码省略.........
stack.Push(stack.Peek());
break;
case OpCode.OP_NIP:
if (stack.Count < 2)
{
throw new ScriptException("Attempted OpCode.OP_NIP on a stack with size < 2");
}
byte[] OPNIPtmpChunk = stack.Pop();
stack.Pop();
stack.Push(OPNIPtmpChunk);
break;
case OpCode.OP_OVER:
if (stack.Count < 2)
{
throw new ScriptException("Attempted OpCode.OP_OVER on a stack with size < 2");
}
stack.Push(stack.ElementAt(1));
break;
case OpCode.OP_PICK:
case OpCode.OP_ROLL:
if (stack.Count < 1)
{
throw new ScriptException("Attempted OpCode.OP_PICK/OpCode.OP_ROLL on an empty stack");
}
long val = CastToBigInteger(stack.Pop()).LongValue;
if (val < 0 || val >= stack.Count)
{
throw new ScriptException("OpCode.OP_PICK/OpCode.OP_ROLL attempted to get data deeper than stack size");
}
byte[] OPROLLtmpChunk = stack.ElementAt((int)val);
if (opcode == OpCode.OP_ROLL)
{
stack.RemoveAt((int)(val + 1));
}
stack.Push(OPROLLtmpChunk);
break;
case OpCode.OP_ROT:
if (stack.Count < 3)
{
throw new ScriptException("Attempted OpCode.OP_ROT on a stack with size < 3");
}
byte[] OPROTtmpChunk3 = stack.Pop();
byte[] OPROTtmpChunk2 = stack.Pop();
byte[] OPROTtmpChunk1 = stack.Pop();
stack.Push(OPROTtmpChunk2);
stack.Push(OPROTtmpChunk3);
stack.Push(OPROTtmpChunk1);
break;
case OpCode.OP_SWAP:
case OpCode.OP_TUCK:
if (stack.Count < 2)
{
throw new ScriptException("Attempted OpCode.OP_SWAP on a stack with size < 2");
}
byte[] OPSWAPtmpChunk2 = stack.Pop();
byte[] OPSWAPtmpChunk1 = stack.Pop();
stack.Push(OPSWAPtmpChunk2);
stack.Push(OPSWAPtmpChunk1);
if (opcode == OpCode.OP_TUCK)
{
stack.Push(OPSWAPtmpChunk2);
}
break;
case OpCode.OP_CAT: