コード例 #1
0
        internal static SharpTreeNode GetNodeByVisibleIndex(SharpTreeNode root, int index)
        {
            root.GetTotalListLength();             // ensure all list lengths are calculated
            Debug.Assert(index >= 0);
            Debug.Assert(index < root.totalListLength);
            SharpTreeNode node = root;

            while (true)
            {
                if (node.left != null && index < node.left.totalListLength)
                {
                    node = node.left;
                }
                else
                {
                    if (node.left != null)
                    {
                        index -= node.left.totalListLength;
                    }
                    if (node.isVisible)
                    {
                        if (index == 0)
                        {
                            return(node);
                        }
                        index--;
                    }
                    node = node.right;
                }
            }
        }
コード例 #2
0
        internal int GetTotalListLength()
        {
            if (totalListLength >= 0)
            {
                return(totalListLength);
            }
            int length = (isVisible ? 1 : 0);

            if (left != null)
            {
                length += left.GetTotalListLength();
            }
            if (right != null)
            {
                length += right.GetTotalListLength();
            }
            return(totalListLength = length);
        }
コード例 #3
0
 internal static SharpTreeNode GetNodeByVisibleIndex(SharpTreeNode root, int index)
 {
     root.GetTotalListLength(); // ensure all list lengths are calculated
     Debug.Assert(index >= 0);
     Debug.Assert(index < root.totalListLength);
     SharpTreeNode node = root;
     while (true) {
         if (node.left != null && index < node.left.totalListLength) {
             node = node.left;
         } else {
             if (node.left != null) {
                 index -= node.left.totalListLength;
             }
             if (node.isVisible) {
                 if (index == 0)
                     return node;
                 index--;
             }
             node = node.right;
         }
     }
 }