コード例 #1
0
        public int IndexOfFirstDuplicate()
        {
            MemoryModuleState last = _states.Last();
            int index = _states.FindIndex(s => s.Equals(last));

            return(index);
        }
コード例 #2
0
        public void Reallocate()
        {
            MemoryBank largest        = _memoryBanks.OrderByDescending(b => b.Blocks).First();
            int        blocksToSpread = largest.Blocks;

            largest.Blocks = 0;

            MemoryBank current = largest;

            for (int x = blocksToSpread; x > 0; x--)
            {
                current = current.Next;
                current.Blocks++;
            }

            // Save off current state
            MemoryModuleState currentState = new MemoryModuleState(_memoryBanks.Select(x => x.Blocks).ToList());

            _states.Add(currentState);
        }