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


C# ImmutableStack.Enumerable方法代码示例

本文整理汇总了C#中ImmutableStack.Enumerable方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableStack.Enumerable方法的具体用法?C# ImmutableStack.Enumerable怎么用?C# ImmutableStack.Enumerable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImmutableStack的用法示例。


在下文中一共展示了ImmutableStack.Enumerable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CallRoutine

        /// <summary>
        /// Calls a routine.
        /// </summary>
        /// <param name="routineType">
        /// The routine type.
        /// </param>
        /// <param name="packedAddress">
        /// The packed address of the routine.
        /// </param>
        /// <param name="arguments">
        /// Routine arguments.
        /// </param>
        protected void CallRoutine(RoutineType routineType, ushort packedAddress, ImmutableStack<ushort> arguments)
        {
            if (packedAddress == 0)
            {
                this.Return(0, routineType);
                return;
            }

            var argumentCount = (byte)arguments.Count();
            var programCounter = this.UnpackRoutineAddress(packedAddress);
            var localVariableCount = this.Memory.ReadByte(programCounter);
            if (localVariableCount > MaximumLocalVariables)
            {
                this.FrontEnd.ErrorNotification(ErrorCondition.InvalidRoutine, "Called a routine at address " + programCounter + " with " + localVariableCount + " local variables.");
            }

            this.CallStack.BeginRoutine(routineType, programCounter + 1, argumentCount, localVariableCount);
            this.InitializeLocalVariables(localVariableCount);
            byte localVariableNumber = 0;
            foreach (var argument in arguments.Enumerable())
            {
                if (localVariableNumber >= localVariableCount)
                {
                    break;
                }

                this.CallStack.WriteLocalVariable(localVariableNumber++, argument);
            }
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:41,代码来源:ZmachineV1.cs

示例2: DictionaryCompare

        /// <summary>
        /// Compares a dictionary entry to a word.
        /// </summary>
        /// <param name="dictionaryEntryAddress">
        /// The dictionary entry address.
        /// </param>
        /// <param name="encodedWord">
        /// The encoded word.
        /// </param>
        /// <returns>
        /// Returns 0 if the entry and word are equal, -1 if the entry comes before the word alphabetically and 1 if the entry comes after the word alphabetically.
        /// </returns>
        private int DictionaryCompare(int dictionaryEntryAddress, ImmutableStack<ushort> encodedWord)
        {
            var entryPosition = 0;
            foreach (var encodedValue in encodedWord.Enumerable())
            {
                var entryPositionValue = this.Memory.ReadWord(dictionaryEntryAddress + entryPosition);
                if (entryPositionValue < encodedValue)
                {
                    return -1;
                }

                if (entryPositionValue > encodedValue)
                {
                    return 1;
                }

                entryPosition += 2;
            }

            return 0;
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:33,代码来源:ZmachineV1.cs

示例3: ZsciiToUnicode

        /// <summary>
        /// Converts zscii text to unicode text.
        /// </summary>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        /// <returns>
        /// The unicode text.
        /// </returns>
        protected string ZsciiToUnicode(ImmutableStack<Zscii> zsciiText)
        {
            ImmutableStack<char> unicodeText = null;
            foreach (var zsciiCharacter in zsciiText.Enumerable())
            {
                if (zsciiCharacter != Zscii.Null)
                {
                    unicodeText = unicodeText.Add(this.ZsciiToUnicode(zsciiCharacter));
                }
            }

            return unicodeText.Reverse().StackToString();
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:22,代码来源:ZmachineV1.cs

示例4: GetNextWord

        /// <summary>
        /// Gets the next word in the zscii text.
        /// </summary>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        /// <param name="wordSeparators">
        /// The word separators.
        /// </param>
        /// <returns>
        /// The next word in the zscii text.
        /// </returns>
        private static ImmutableStack<Zscii> GetNextWord(ref ImmutableStack<Zscii> zsciiText, ImmutableStack<Zscii> wordSeparators)
        {
            ImmutableStack<Zscii> word = null;
            while (zsciiText != null)
            {
                var zsciiCharacter = zsciiText.Top;
                foreach (var wordSeparator in wordSeparators.Enumerable())
                {
                    if (zsciiCharacter == wordSeparator)
                    {
                        if (word == null)
                        {
                            word = word.Add(zsciiCharacter);
                            zsciiText = zsciiText.Tail;
                        }

                        return word.Reverse();
                    }
                }

                word = word.Add(zsciiCharacter);
                zsciiText = zsciiText.Tail;
            }

            return word.Reverse();
        }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:38,代码来源:ZmachineV1.cs

示例5: WriteZsciiToMemory

 /// <summary>
 /// Writes zscii text to memory.
 /// </summary>
 /// <param name="address">
 /// The memory address to begin writing.
 /// </param>
 /// <param name="zsciiText">
 /// The zscii text.
 /// </param>
 protected void WriteZsciiToMemory(int address, ImmutableStack<Zscii> zsciiText)
 {
     foreach (var zsciiCharacter in zsciiText.Enumerable())
     {
         this.Memory.WriteByte(address++, (byte)zsciiCharacter);
     }
 }
开发者ID:DevTheo,项目名称:IFControlDemo,代码行数:16,代码来源:ZmachineV1.cs


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