示例#1
0
        public bool ShouldSplit(MemoryPosition memoryPosition, int memoryPointer)
        {
            if (memoryPointer == Memory.REGISTER_SIZE)
            {
                return(false);
            }

            if (memoryPosition.GetAction(memoryPointer) != null)
            {
                return(true);
            }
            return(false);
        }
示例#2
0
        public void SetValue(MemoryPosition memoryPosition, int memoryPointer, MemoryValue value)
        {
            // splitnode should never be a leaf

            bool?memoryAction = memoryPosition.GetAction(memoryPointer);

            bool toZero, toOne;

            if (memoryAction.HasValue)
            {
                toOne  = memoryAction.Value;
                toZero = !toOne;
            }
            else
            {
                toOne  = true;
                toZero = true;
            }

            if (toZero)
            {
                if (Zero.ShouldSplit(memoryPosition, memoryPointer + 1))
                {
                    Zero = Zero.Split();
                }
                Zero.SetValue(memoryPosition, memoryPointer + 1, value);
            }
            if (toOne)
            {
                if (One.ShouldSplit(memoryPosition, memoryPointer + 1))
                {
                    One = One.Split();
                }
                One.SetValue(memoryPosition, memoryPointer + 1, value);
            }
        }