コード例 #1
0
 public static void Build(DirectoryEntry rootEntry)
 {
     if (rootEntry.Members.Count > 0)
     {
         rootEntry.MembersTreeNodeDID = DirectoryTree.BuildStorageEntry(rootEntry);
     }
 }
コード例 #2
0
        private static int BuildStorageEntry(DirectoryEntry storageEntry)
        {
            RedBlackTree <DirectoryEntry> redBlackTree = new RedBlackTree <DirectoryEntry>();

            foreach (DirectoryEntry directoryEntry in storageEntry.Members.Values)
            {
                redBlackTree.Add(directoryEntry);
            }
            foreach (RedBlackTreeNode <DirectoryEntry> current in redBlackTree.InorderTreeWalk(redBlackTree.Root))
            {
                DirectoryEntry directoryEntry = current.Data;
                directoryEntry.NodeColor     = DirectoryTree.GetNodeColor(current.Color);
                directoryEntry.LeftChildDID  = DirectoryTree.GetNodeID(current.Left);
                directoryEntry.RightChildDID = DirectoryTree.GetNodeID(current.Right);
                if (directoryEntry.Members.Count > 0)
                {
                    directoryEntry.EntryType          = 1;
                    directoryEntry.MembersTreeNodeDID = DirectoryTree.BuildStorageEntry(directoryEntry);
                }
                else
                {
                    directoryEntry.EntryType          = 2;
                    directoryEntry.MembersTreeNodeDID = -1;
                }
            }
            return(redBlackTree.Root.Data.ID);
        }