コード例 #1
0
ファイル: SkipTree.cs プロジェクト: veboys/UIForia
        private void TraversePreOrderCallbackStep(SkipTreeNode startNode, Action <T> traverseFn, bool includeDisabled)
        {
            if (startNode.isDisabled && !includeDisabled)
            {
                return;
            }

            if (startNode != root)
            {
                traverseFn(startNode.item);
            }

            if (startNode.firstChild == null)
            {
                return;
            }

            LightStack <SkipTreeNode> stack = LightStack <SkipTreeNode> .Get();

            AddChildrenToLightStack(stack, startNode, includeDisabled);

            while (stack.Count > 0)
            {
                SkipTreeNode current = stack.Pop();
                traverseFn(current.item);
                AddChildrenToLightStack(stack, current, includeDisabled);
            }

            LightStack <SkipTreeNode> .Release(ref stack);
        }
コード例 #2
0
ファイル: SkipTree.cs プロジェクト: veboys/UIForia
        private void TraverseNodesStep <U>(U closureArg, SkipTreeNode startNode, Action <U, SkipTreeNode> traverseFn, bool includeDisabled)
        {
            if (startNode.isDisabled && !includeDisabled)
            {
                return;
            }

            traverseFn(closureArg, startNode);

            if (startNode.firstChild == null)
            {
                return;
            }

            LightStack <SkipTreeNode> stack = LightStack <SkipTreeNode> .Get();

            AddChildrenToLightStack(stack, startNode, includeDisabled);

            while (stack.Count > 0)
            {
                SkipTreeNode current = stack.Pop();
                traverseFn(closureArg, current);
                AddChildrenToLightStack(stack, current, includeDisabled);
            }

            LightStack <SkipTreeNode> .Release(ref stack);
        }
コード例 #3
0
ファイル: SkipTree.cs プロジェクト: veboys/UIForia
        private void TraversePreOrderCallbackStep <U>(SkipTreeNode startNode, U closureArg, Action <U, T> traverseFn, bool includeDisabled)
        {
            LightStack <SkipTreeNode> stack = LightStack <SkipTreeNode> .Get();

            AddChildrenToLightStack(stack, startNode, includeDisabled);
            while (stack.Count > 0)
            {
                SkipTreeNode current = stack.Pop();
                traverseFn(closureArg, current.item);
                AddChildrenToLightStack(stack, current, includeDisabled);
            }

            LightStack <SkipTreeNode> .Release(ref stack);
        }
コード例 #4
0
ファイル: SkipTree.cs プロジェクト: veboys/UIForia
        private void ConditionalTraversePreOrderStep <U>(SkipTreeNode node, U closureArg, Func <T, U, bool> traverseFn)
        {
            LightStack <SkipTreeNode> stack = LightStack <SkipTreeNode> .Get();

            AddChildrenToLightStack(stack, node, true);

            while (stack.Count > 0)
            {
                SkipTreeNode current = stack.Pop();
                if (traverseFn(current.item, closureArg))
                {
                    AddChildrenToLightStack(stack, current, true);
                }
            }

            LightStack <SkipTreeNode> .Release(ref stack);
        }
コード例 #5
0
ファイル: SkipTree.cs プロジェクト: veboys/UIForia
        public void RemoveHierarchy(IHierarchical item)
        {
            SkipTreeNode              node;
            IHierarchical             element = item.Element;
            LightStack <SkipTreeNode> stack   = LightStack <SkipTreeNode> .Get();

            SkipTreeNode parent = FindParent(item) ?? root;

            if (!nodeMap.TryGetValue(element.UniqueId, out node))
            {
                SkipTreeNode trail = null;
                SkipTreeNode ptr   = parent.firstChild;
                while (ptr != null)
                {
                    if (IsDescendantOf(ptr.item, item))
                    {
                        if (ptr == parent.firstChild)
                        {
                            parent.firstChild = ptr.nextSibling;
                        }
                        else if (trail != null)
                        {
                            trail.nextSibling = ptr.nextSibling;
                        }

                        stack.Push(ptr);
                    }
                    else
                    {
                        trail = ptr;
                    }

                    ptr = ptr.nextSibling;
                }
            }
            else
            {
                SkipTreeNode nodeNext = node.nextSibling;
                SkipTreeNode nodePrev = FindPreviousSibling(node);

                if (nodePrev != null)
                {
                    nodePrev.nextSibling = nodeNext;
                }
                else if (parent.firstChild == node)
                {
                    parent.firstChild = nodeNext;
                }

                stack.Push(node);
            }

            while (stack.Count > 0)
            {
                SkipTreeNode current = stack.Pop();
                nodeMap.Remove(current.item.UniqueId);
                AddChildrenToLightStack(stack, current, true);
            }

            onTreeChanged?.Invoke(TreeChangeType.HierarchyRemoved);
            LightStack <SkipTreeNode> .Release(ref stack);
        }