public T GetKth(uint k) { if (k < 0 || k >= Size) { throw new IndexOutOfRangeException(); } return(root.GetKth(k).value); }
internal TreapNode GetKth(uint k) { uint pos = left != null ? left.size : 0; int b = k.CompareTo(pos); if (b == 0) { return(this); } if (b < 0) { return(left.GetKth(k)); } else { return(right.GetKth(k - pos - 1)); } }