Пример #1
0
        public static MemoryTreeNode GetOrLoadNode(TreeFile TreeFile, MemoryTreeNode ParentNode, NodePointer Pointer)
        {
            if (Pointer.IsFirstPreviousPointer)
            {
                if (ParentNode.PreviousPointer != null)
                {
                    return(ParentNode.PreviousPointer);
                }
                else
                {
                    TreeNode node = TreeFile.ReadNode(Pointer.PositionPointer);
                    if (node == null)
                    {
                        return(null);
                    }

                    MemoryTreeNode newcachenode = new MemoryTreeNode(node);
                    newcachenode.Parent = ParentNode;
                    newcachenode.IsParentPreviousPointer = Pointer.IsFirstPreviousPointer;
                    newcachenode.ParentNodeKey           = Pointer.KeyToPosition;
                    newcachenode.Level = ParentNode.Level + 1;

                    if (newcachenode.Level < TreeFile.MaxCacheLevel)
                    {
                        ParentNode.PreviousPointer = newcachenode;
                    }
                    return(newcachenode);
                }
            }
            else
            {
                if (ParentNode.Children.ContainsKey(Pointer.PositionPointer))
                {
                    return(ParentNode.Children[Pointer.PositionPointer]);
                }
                else
                {
                    TreeNode node = TreeFile.ReadNode(Pointer.PositionPointer);
                    if (node == null)
                    {
                        return(null);
                    }
                    MemoryTreeNode newcachenode = new MemoryTreeNode(node);
                    newcachenode.Parent = ParentNode;
                    newcachenode.IsParentPreviousPointer = Pointer.IsFirstPreviousPointer;
                    newcachenode.ParentNodeKey           = Pointer.KeyToPosition;
                    newcachenode.Level = ParentNode.Level + 1;

                    if (newcachenode.Level < TreeFile.MaxCacheLevel)
                    {
                        ParentNode.Children[Pointer.PositionPointer] = newcachenode;
                    }
                    return(newcachenode);
                }
            }
        }
Пример #2
0
 public static void NodeChange(TreeFile tree, MemoryTreeNode node)
 {
     if (node == null)
     {
         return;
     }
     if (node.TreeNode.TypeIndicator == EnumValues.TypeIndicator.root)
     {
         var treenode     = tree.ReadNode(node.TreeNode.DiskPosition);
         var newrootcache = new MemoryTreeNode(treenode);
         tree.RootCache = newrootcache;
     }
     else
     {
         var parent = node.Parent;
         if (parent != null)
         {
             if (node.IsParentPreviousPointer)
             {
                 parent.PreviousPointer = null;
             }
             else
             {
                 parent.Children.Remove(node.TreeNode.DiskPosition);
             }
         }
     }
     node = null;
 }
Пример #3
0
        public static void NodeReload(TreeFile tree, MemoryTreeNode node)
        {
            var newnode = tree.ReadNode(node.TreeNode.DiskPosition);

            node.TreeNode = newnode;
        }