当前位置: 首页>>代码示例>>C#>>正文


C# Stack.RemoveAt方法代码示例

本文整理汇总了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());
 }
开发者ID:Virus-X,项目名称:CoinSharp,代码行数:11,代码来源:UtilsTest.cs

示例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:
开发者ID:Virus-X,项目名称:CoinSharp,代码行数:67,代码来源:ScriptRunner.cs


注:本文中的Stack.RemoveAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。