Jurassic.Library.SparseArray.DeleteRange C# (CSharp) Method

DeleteRange() private method

Deletes (sets to null) a range of array elements.
private DeleteRange ( uint start, uint length, Node parentNode, Node node, int nodeIndex, int nodeDepth ) : void
start uint The index of the first array element to delete.
length uint The number of array elements to delete.
parentNode Node The parent node of the node to delete from. Can be null.
node Node The node to delete from.
nodeIndex int The index of the node, in the parent node's array.
nodeDepth int The depth of the tree, treating as the root.
return void
        private void DeleteRange(uint start, uint length, Node parentNode, Node node, int nodeIndex, int nodeDepth)
        {
            uint nodeLength = (NodeShift * nodeDepth) >= 32 ? uint.MaxValue : 1u << NodeShift * nodeDepth;
            uint nodeStart = nodeLength * (uint)nodeIndex;
            if (parentNode != null && (nodeStart >= start + length || nodeStart + nodeLength <= start))
            {
                // Delete the entire node.
                parentNode.array[nodeIndex] = null;
                return;
            }

            if (nodeDepth == 1)
            {
                // The node is a leaf node.
                for (int i = 0; i < NodeSize; i++)
                {
                    uint index = (uint)(nodeStart + i);
                    if (index >= start && index < start + length)
                        node.array[i] = null;
                }
            }
            else
            {
                // The node is a branch node.
                for (int i = 0; i < NodeSize; i++)
                {
                    var element = node.array[i] as Node;
                    if (element != null)
                    {
                        DeleteRange(start, length, node, element, i, nodeDepth - 1);
                    }
                }
            }
        }

Same methods

SparseArray::DeleteRange ( uint start, uint length ) : void