Microsoft.R.Core.AST.AstNode.RemoveChildren C# (CSharp) Method

RemoveChildren() public method

public RemoveChildren ( int start, int count ) : void
start int
count int
return void
        public void RemoveChildren(int start, int count) {
            if (count == 0)
                return;

            if (start < 0 || start >= Children.Count)
                throw new ArgumentOutOfRangeException(nameof(start));

            if (count < 0 || count > Children.Count || start + count > Children.Count)
                throw new ArgumentOutOfRangeException(nameof(count));

            if (Children.Count == count) {
                _children = new TextRangeCollection<IAstNode>();
            } else {
                var newChildren = new IAstNode[Children.Count - count];

                int j = 0;

                for (int i = 0; i < start; i++, j++)
                    newChildren[j] = Children[i];

                for (int i = start; i < start + count; i++)
                    Children[i].Parent = null;

                for (int i = start + count; i < Children.Count; i++, j++)
                    newChildren[j] = Children[i];

                _children = new TextRangeCollection<IAstNode>(newChildren);
            }
        }