/// <summary> /// 挂接子节点 /// </summary> /// <param name="childNode"></param> /// <returns></returns> public bool AttachChild(CTreeNode childNode) { if (childNode == null) { return(false); } if (childNode.m_NodeParent != null) { return(false); } UInt32 uChildID = childNode.GetNodeID(); if (ContainChild(uChildID) == true) { return(false); } // 挂接到父节点 childNode.m_NodeParent = this; // 添加到子节点 if (m_Children == null) { m_Children = new QuickList <UInt32, CTreeNode>(); } if (m_Children.Add(uChildID, childNode) == false) { childNode.m_NodeParent = null; return(false); } return(true); }
/// <summary> /// 获取子节点 /// </summary> /// <param name="uChildId"></param> /// <returns></returns> public CTreeNode GetChildNode(UInt32 uChildId) { if (m_Children == null) { return(null); } Int32 nSize = m_Children.Count; for (Int32 i = 0; i < nSize; ++i) { CTreeNode node = m_Children[i]; if (node == null) { continue; } if (node.GetNodeID() == uChildId) { return(node); } } return(null); }
/// <summary> /// 包含子节点 /// </summary> /// <param name="uNodeId"></param> /// <returns></returns> public bool ContainChild(UInt32 uNodeId) { if (m_Children == null) { return(false); } Int32 nSize = m_Children.Count; for (Int32 i = 0; i < nSize; ++i) { CTreeNode node = m_Children[i]; if (node == null) { continue; } if (node.GetNodeID() == uNodeId) { return(true); } } return(false); }