/// <summary>Gets the key at the supplied index.</summary> /// <param name="index">The zero-based index of the key to get.</param> /// <returns>The key at <em>index</em>.</returns> /// <remarks>This is a O(log <em>n</em>) operation.</remarks> /// <exception cref="ArgumentOutOfRangeException">When <em>index</em> is less than zero or greater than or equal to the number of keys.</exception> public TKey ElementAt(int index) { if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException(nameof(index), "Argument is out of the range of valid values."); } var leaf = tree.Find(index, out int leafIndex); return(leaf.GetKey(leafIndex)); }