private void AddChildrenRecursive(BackendData.Foo foo, int numChildren, bool force) { if (this.IDCounter > this.m_MaxItems || foo.depth >= 12 || !force && (double)Random.value < 0.5) { return; } if (foo.children == null) { foo.children = new List <BackendData.Foo>(numChildren); } for (int index = 0; index < numChildren; ++index) { foo.children.Add(new BackendData.Foo("Tud" + (object)this.IDCounter, foo.depth + 1, ++this.IDCounter) { parent = foo }); } if (this.IDCounter > this.m_MaxItems) { return; } using (List <BackendData.Foo> .Enumerator enumerator = foo.children.GetEnumerator()) { while (enumerator.MoveNext()) { this.AddChildrenRecursive(enumerator.Current, Random.Range(3, 15), false); } } }
public void ReparentSelection(BackendData.Foo parentItem, BackendData.Foo insertAfterItem, List <BackendData.Foo> draggedItems) { foreach (BackendData.Foo current in draggedItems) { current.parent.children.Remove(current); current.parent = parentItem; } if (!parentItem.hasChildren) { parentItem.children = new List <BackendData.Foo>(); } List <BackendData.Foo> list = new List <BackendData.Foo>(parentItem.children); int index = 0; if (parentItem == insertAfterItem) { index = 0; } else { int num = parentItem.children.IndexOf(insertAfterItem); if (num >= 0) { index = num + 1; } else { Debug.LogError("Did not find insertAfterItem, should be a child of parentItem!!"); } } list.InsertRange(index, draggedItems); parentItem.children = list; }
private void AddChildrenRecursive(BackendData.Foo foo, int numChildren, bool force) { if (this.IDCounter > this.m_MaxItems) { return; } if (foo.depth >= 12) { return; } if (!force && UnityEngine.Random.value < 0.5f) { return; } if (foo.children == null) { foo.children = new List <BackendData.Foo>(numChildren); } for (int i = 0; i < numChildren; i++) { BackendData.Foo foo2 = new BackendData.Foo("Tud" + this.IDCounter, foo.depth + 1, ++this.IDCounter); foo2.parent = foo; foo.children.Add(foo2); } if (this.IDCounter > this.m_MaxItems) { return; } foreach (BackendData.Foo current in foo.children) { this.AddChildrenRecursive(current, UnityEngine.Random.Range(3, 15), false); } }
private HashSet <int> GetParentsBelowRecursive(BackendData.Foo searchFromThis) { HashSet <int> hashSet = new HashSet <int>(); BackendData.GetParentsBelowRecursive(searchFromThis, hashSet); return(hashSet); }
private HashSet <int> GetParentsBelowStackBased(BackendData.Foo searchFromThis) { Stack <BackendData.Foo> fooStack = new Stack <BackendData.Foo>(); fooStack.Push(searchFromThis); HashSet <int> intSet = new HashSet <int>(); while (fooStack.Count > 0) { BackendData.Foo foo = fooStack.Pop(); if (foo.hasChildren) { intSet.Add(foo.id); using (List <BackendData.Foo> .Enumerator enumerator = foo.children.GetEnumerator()) { while (enumerator.MoveNext()) { BackendData.Foo current = enumerator.Current; fooStack.Push(current); } } } } return(intSet); }
private void AddVisibleChildrenRecursive(BackendData.Foo source, TreeViewItem dest) { if (this.IsExpanded(source.id)) { if (source.children == null || source.children.Count <= 0) { return; } dest.children = new List <TreeViewItem>(source.children.Count); for (int index = 0; index < source.children.Count; ++index) { BackendData.Foo child = source.children[index]; dest.children.Add((TreeViewItem) new FooTreeViewItem(child.id, dest.depth + 1, dest, child.name, child)); ++this.itemCounter; this.AddVisibleChildrenRecursive(child, dest.children[index]); } } else { if (!source.hasChildren) { return; } dest.children = new List <TreeViewItem>() { new TreeViewItem(-1, -1, (TreeViewItem)null, string.Empty) }; } }
private HashSet <int> GetParentsBelowRecursive(BackendData.Foo searchFromThis) { HashSet <int> parentIDs = new HashSet <int>(); BackendData.GetParentsBelowRecursive(searchFromThis, parentIDs); return(parentIDs); }
public static BackendData.Foo FindNodeRecursive(BackendData.Foo item, int id) { if (item == null) { return((BackendData.Foo)null); } if (item.id == id) { return(item); } if (item.children == null) { return((BackendData.Foo)null); } using (List <BackendData.Foo> .Enumerator enumerator = item.children.GetEnumerator()) { while (enumerator.MoveNext()) { BackendData.Foo nodeRecursive = BackendData.FindNodeRecursive(enumerator.Current, id); if (nodeRecursive != null) { return(nodeRecursive); } } } return((BackendData.Foo)null); }
public void GenerateData(int maxNumItems) { this.m_MaxItems = maxNumItems; this.IDCounter = 1; this.m_Root = new BackendData.Foo("Root", 0, 0); while (this.IDCounter < this.m_MaxItems) this.AddChildrenRecursive(this.m_Root, Random.Range(3, 15), true); }
public void GenerateData(int maxNumItems) { this.m_MaxItems = maxNumItems; this.IDCounter = 1; this.m_Root = new BackendData.Foo("Root", 0, 0); while (this.IDCounter < this.m_MaxItems) { this.AddChildrenRecursive(this.m_Root, Random.Range(3, 15), true); } }
private static void GetParentsBelowRecursive(BackendData.Foo item, HashSet <int> parentIDs) { if (!item.hasChildren) { return; } parentIDs.Add(item.id); foreach (BackendData.Foo current in item.children) { BackendData.GetParentsBelowRecursive(current, parentIDs); } }
public HashSet <int> GetParentsBelow(int id) { BackendData.Foo foo = BackendData.FindItemRecursive(this.root, id); if (foo == null) { return(new HashSet <int>()); } if (this.m_RecursiveFindParentsBelow) { return(this.GetParentsBelowRecursive(foo)); } return(this.GetParentsBelowStackBased(foo)); }
public HashSet <int> GetParentsBelow(int id) { BackendData.Foo nodeRecursive = BackendData.FindNodeRecursive(this.root, id); if (nodeRecursive == null) { return(new HashSet <int>()); } if (this.m_RecursiveFindParentsBelow) { return(this.GetParentsBelowRecursive(nodeRecursive)); } return(this.GetParentsBelowStackBased(nodeRecursive)); }
protected override HashSet <int> GetParentsAbove(int id) { HashSet <int> set = new HashSet <int>(); for (BackendData.Foo foo = BackendData.FindNodeRecursive(this.m_Backend.root, id); foo != null; foo = foo.parent) { if (foo.parent != null) { set.Add(foo.parent.id); } } return(set); }
private void AddChildrenRecursive(BackendData.Foo source, TreeViewItem dest) { if (source.hasChildren) { dest.children = new List <TreeViewItem>(source.children.Count); for (int i = 0; i < source.children.Count; i++) { BackendData.Foo foo = source.children[i]; dest.children.Add(new FooTreeViewItem(foo.id, dest.depth + 1, dest, foo.name, foo)); this.itemCounter++; this.AddChildrenRecursive(foo, dest.children[i]); } } }
private static void GetParentsBelowRecursive(BackendData.Foo item, HashSet <int> parentIDs) { if (!item.hasChildren) { return; } parentIDs.Add(item.id); using (List <BackendData.Foo> .Enumerator enumerator = item.children.GetEnumerator()) { while (enumerator.MoveNext()) { BackendData.GetParentsBelowRecursive(enumerator.Current, parentIDs); } } }
private void AddChildrenRecursive(BackendData.Foo source, TreeViewItem dest) { if (!source.hasChildren) { return; } dest.children = new List <TreeViewItem>(source.children.Count); for (int index = 0; index < source.children.Count; ++index) { BackendData.Foo child = source.children[index]; dest.children.Add((TreeViewItem) new FooTreeViewItem(child.id, dest.depth + 1, dest, child.name, child)); ++this.itemCounter; this.AddChildrenRecursive(child, dest.children[index]); } }
private HashSet <int> GetParentsBelowStackBased(BackendData.Foo searchFromThis) { Stack <BackendData.Foo> stack = new Stack <BackendData.Foo>(); stack.Push(searchFromThis); HashSet <int> hashSet = new HashSet <int>(); while (stack.Count > 0) { BackendData.Foo foo = stack.Pop(); if (foo.hasChildren) { hashSet.Add(foo.id); foreach (BackendData.Foo current in foo.children) { stack.Push(current); } } } return(hashSet); }
private void AddVisibleChildrenRecursive(BackendData.Foo source, TreeViewItem dest) { if (this.IsExpanded(source.id)) { if ((source.children != null) && (source.children.Count > 0)) { dest.children = new List <TreeViewItem>(source.children.Count); for (int i = 0; i < source.children.Count; i++) { BackendData.Foo foo = source.children[i]; dest.children.Add(new FooTreeViewItem(foo.id, dest.depth + 1, dest, foo.name, foo)); this.itemCounter++; this.AddVisibleChildrenRecursive(foo, dest.children[i]); } } } else if (source.hasChildren) { dest.children = new List <TreeViewItem> { new TreeViewItem(-1, -1, null, string.Empty) }; } }
public void ReparentSelection(BackendData.Foo parentItem, BackendData.Foo insertAfterItem, List <BackendData.Foo> draggedItems) { using (List <BackendData.Foo> .Enumerator enumerator = draggedItems.GetEnumerator()) { while (enumerator.MoveNext()) { BackendData.Foo current = enumerator.Current; current.parent.children.Remove(current); current.parent = parentItem; } } if (!parentItem.hasChildren) { parentItem.children = new List <BackendData.Foo>(); } List <BackendData.Foo> fooList = new List <BackendData.Foo>((IEnumerable <BackendData.Foo>)parentItem.children); int index = 0; if (parentItem == insertAfterItem) { index = 0; } else { int num = parentItem.children.IndexOf(insertAfterItem); if (num >= 0) { index = num + 1; } else { Debug.LogError((object)"Did not find insertAfterItem, should be a child of parentItem!!"); } } fooList.InsertRange(index, (IEnumerable <BackendData.Foo>)draggedItems); parentItem.children = fooList; }
public static BackendData.Foo FindItemRecursive(BackendData.Foo item, int id) { if (item == null) { return(null); } if (item.id == id) { return(item); } if (item.children == null) { return(null); } foreach (BackendData.Foo current in item.children) { BackendData.Foo foo = BackendData.FindItemRecursive(current, id); if (foo != null) { return(foo); } } return(null); }
public FooTreeViewItem(int id, int depth, TreeViewItem parent, string displayName, BackendData.Foo foo) : base(id, depth, parent, displayName) { this.foo = foo; }