Esempio n. 1
0
        // change to Main to run.
        public static void none(string[] args)
        {
            var creatures = new Creature2[100];

            // inefficient
            // Age X.Y Age X.Y Age X.Y

            // efficient for modern cpus. Contiguous memory access to creature coordinates.
            // Age Age Age Age // array
            // X X X X // array
            // Y Y Y Y // array

            // old
            foreach (Creature2 c in creatures)
            {
                c.X++;
            }

            // new referencing into creatures.x. proxies for performance increase
            Creatures creature2 = new Creatures(100); // Structure of Array

            foreach (Creatures.CreatureProxy cp in creature2)
            {
                cp.X++;
            }
        }
Esempio n. 2
0
 public CreatureProxy(Creatures creatures, int index)
 {
     _creatures = creatures;
     _index     = index;
 }