/// <summary> /// Gets/Sets a single character. /// Runs in O(lg N) for random access. Sequential read-only access benefits from a special optimization and runs in amortized O(1). /// </summary> public char this [int index] { get { if (root is LeafNode) { return(root [index]); } var leaf = myLastLeaf; if (leaf == null || index < leaf.offset || index >= leaf.offset + leaf.leafNode.Length) { myLastLeaf = leaf = FindLeaf(index, 0); } return(leaf.leafNode [index - leaf.offset]); } }
/// <summary> /// Gets/Sets a single character. /// Runs in O(lg N) for random access. Sequential read-only access benefits from a special optimization and runs in amortized O(1). /// </summary> public char this [int index] { get { if (root is LeafNode) { return root [index]; } var leaf = myLastLeaf; if (leaf == null || index < leaf.offset || index >= leaf.offset + leaf.leafNode.Length) { myLastLeaf = leaf = FindLeaf (index, 0); } return leaf.leafNode [index - leaf.offset]; } }