Example #1
0
 public T GetKth(uint k)
 {
     if (k < 0 || k >= Size)
     {
         throw new IndexOutOfRangeException();
     }
     return(root.GetKth(k).value);
 }
Example #2
0
            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));
                }
            }