コード例 #1
0
ファイル: LifeNode.cs プロジェクト: cmaughan/NodeLife
        public static LifeNodeBase InitSpace(int dimension, InitLeaf initFunc)
        {
            if (!Utils.IsPowerOfTwo(dimension))
            {
                throw new InvalidOperationException("dimension must be a power of 2");
            }
            if (dimension == 2)
            {
                return(initFunc());
            }
            LifeNodeBase subNode1 = LifeNode.InitSpace(dimension / 2, initFunc);
            LifeNodeBase subNode2 = LifeNode.InitSpace(dimension / 2, initFunc);
            LifeNodeBase subNode3 = LifeNode.InitSpace(dimension / 2, initFunc);
            LifeNodeBase subNode4 = LifeNode.InitSpace(dimension / 2, initFunc);

            return(LifeNode.CreateNode(subNode1, subNode2, subNode3, subNode4));
        }
コード例 #2
0
ファイル: LifeNode.cs プロジェクト: gossmanster/NodeLife
 public static LifeNodeBase InitSpace(int dimension, InitLeaf initFunc)
 {
     if (!Utils.IsPowerOfTwo(dimension))
         throw new InvalidOperationException("dimension must be a power of 2");
     if (dimension == 2)
         return initFunc();
     LifeNodeBase subNode1 = LifeNode.InitSpace(dimension / 2, initFunc);
     LifeNodeBase subNode2 = LifeNode.InitSpace(dimension / 2, initFunc);
     LifeNodeBase subNode3 = LifeNode.InitSpace(dimension / 2, initFunc);
     LifeNodeBase subNode4 = LifeNode.InitSpace(dimension / 2, initFunc);
     return LifeNode.CreateNode(subNode1, subNode2, subNode3, subNode4);
 }