private T2 m_GetBranchAtIdInAll(int id) { T2 t = default(T2); if (id == TreeNodeID) { IBaseTreeNode btn = this; return((T2)btn); } if (branches.ContainsKey(id)) { t = branches[id]; } else { List <int> branchList = new List <int>(branches.Keys); for (int i = 0; i < branchList.Count; i++) { T2 cnode = branches[branchList[i]]; BaseTreeNode <T1, T2> _C = cnode as BaseTreeNode <T1, T2>; T2 node = _C.GetBranchAtIdInAll(id); if (node != null) { t = node; break; } } } return(t); }
private void m_DicConnectParent() { if (parent == null) { BaseTreeNode <T1, T2> _P = parent as BaseTreeNode <T1, T2>; IBaseTreeNode _C = this; _P.RemoveBranch((T2)_C); } }
private T2 m_GetBranchAtIdInNextDepth(int id) { if (id == TreeNodeID) { IBaseTreeNode btn = this; return((T2)btn); } if (branches.ContainsKey(id)) { return(branches[id]); } return(default(T2)); }
private bool m_InsertBranch(T2 child) { if (ContainBranch(child)) { return(false); } branches.Add(child.TreeNodeID, child); IBaseTreeNode _P = this as IBaseTreeNode; BaseTreeNode <T1, T2> _C = child as BaseTreeNode <T1, T2>; _C.SetParent((T2)_P); return(true); }
void IBaseTreeNode.ReviseKeys() { lock (branches) { List <int> keys = new List <int>(branches.Keys); for (int i = 0; i < keys.Count; i++) { IBaseTreeNode t = branches[keys[i]]; if (keys[i] != t.TreeNodeID) { branches.Remove(keys[i]); branches[t.TreeNodeID] = (T2)t; } } } }
private bool m_SetBranch(int childIndex, T2 child) { if (ContainBranch(child)) { return(false); } if (childIndex < branches.Count) { T2 t2 = m_GetBranch(childIndex); BaseTreeNode <T1, T2> _T2 = t2 as BaseTreeNode <T1, T2>; _T2.DicConnectParent(); } branches[child.TreeNodeID] = child; IBaseTreeNode _P = this as IBaseTreeNode; BaseTreeNode <T1, T2> _C = child as BaseTreeNode <T1, T2>; _C.SetParent((T2)_P); return(true); }
private int m_GetBranch(int depth, int childIndex, ref T2 t2) { if (depth == 0) { IBaseTreeNode _N = this; t2 = (T2)_N; return(0); } int currentIndex = 0; List <int> branchList = new List <int>(branches.Keys); for (int i = 0; i < branchList.Count; i++) { T2 node = branches[branchList[i]]; if (depth == 1) { if (childIndex == i) { t2 = node; currentIndex = 0; break; } currentIndex++; } else if (depth > 1) { BaseTreeNode <T1, T2> _C = node as BaseTreeNode <T1, T2>; int _cIndex = _C.m_GetBranch(depth - 1, childIndex - currentIndex, ref t2); if (_cIndex == 0) { currentIndex = 0; break; } currentIndex += _cIndex; } } return(currentIndex); }
private void m_SetParent(T2 pnode) { parent = pnode; }