/// <summary> /// Retrieves the text for a portion of the rope. /// Runs in O(lg N + M), where M=<paramref name="length"/>. /// </summary> /// <exception cref="ArgumentOutOfRangeException">offset or length is outside the valid range.</exception> /// <remarks> /// This method counts as a read access and may be called concurrently to other read accesses. /// </remarks> public static string ToString(this Rope <char> rope, int startIndex, int length) { if (rope == null) { throw new ArgumentNullException(nameof(rope)); } #if DEBUG if (length < 0) { throw new ArgumentOutOfRangeException(nameof(length), length, "Value must be >= 0"); } #endif if (length == 0) { return(string.Empty); } char[] buffer = new char[length]; rope.CopyTo(startIndex, buffer, 0, length); return(new string(buffer)); }