public void Split(int splitIndex) { Debug.Assert(!IsSorted); Debug.Assert(splitIndex > StartIndex && splitIndex < EndIndex); Debug.Assert(this.splitIndex < 0 && LeftNode == null && RightNode == null); this.splitIndex = splitIndex; LeftNode = new PartitionNode(StartIndex, splitIndex, Depth + 1); RightNode = new PartitionNode(splitIndex, EndIndex, Depth + 1); }
public PartitionNode Find(int index) { PartitionNode x = this; while (x.splitIndex >= 0) { if (index < x.splitIndex) { x = x.LeftNode !; } else { x = x.RightNode !; } } return(x); }