Пример #1
0
        bool Sync(TestUniNode uniTree, TestUniNode uniNode, byte uniDepth, int uniIt, UFTree ufTree, Int64 ufNode, object userData)
        {
            Assert.AreEqual(uniDepth, ufTree.GetDepth(ufNode), String.Format("ufNode: {0}", ufNode));
            TestUfTree tufTree = (TestUfTree)ufTree;

            Assert.AreEqual(uniDepth == 0 ? 0 : uniNode.ChildIndex + 1, uniIt);
            Assert.AreEqual(uniNode.Id, tufTree.Nodes[ufNode].Id);
            Assert.AreEqual("bla", userData);
            return(true);
        }
Пример #2
0
 void CreateTestUniTree(TestUniNode node, ref int nodeIdx, int curDepth, int depthLimit, int childCount)
 {
     if (curDepth >= depthLimit)
     {
         return;
     }
     node.Children = new TestUniNode[childCount];
     for (int c = 0; c < childCount; ++c)
     {
         node.Children[c] = new TestUniNode {
             Id = ++nodeIdx, ChildIndex = c
         };
         CreateTestUniTree(node.Children[c], ref nodeIdx, curDepth + 1, depthLimit, childCount);
     }
 }
Пример #3
0
        public void Test_Sync()
        {
            int        nodesCount = 1 + 4 + 4 * 4 + 4 * 4 * 4;
            int        idx;
            TestUfTree ufTree = new TestUfTree(nodesCount);

            idx = 0;
            CreateTestUfTree(ufTree, ref idx, 0, 3, 4);


            TestUniNode uniRoot = new TestUniNode();

            idx = 0;
            CreateTestUniTree(uniRoot, ref idx, 0, 3, 4);

            string userData = "bla";

            SyncUniAndUF <int> .Sync(uniRoot, ufTree, Sync, userData);
        }
Пример #4
0
 public static bool TreeGetChild(TestUniNode tree, TestUniNode n, ref int i, out TestUniNode child)
 {
     return((i < n.Children.Length ? child = n.Children[i++] : child = null) != null);
 }