示例#1
0
        static unsafe void Swap <TX>(TX *left, TX *right) where TX : unmanaged
        {
            var tmp = *left;

            *left  = *right;
            *right = tmp;
        }
示例#2
0
 static unsafe void SwapIfGreater <TX>(TX *left, TX *right) where TX : unmanaged, IComparable <TX>
 {
     if ((*left).CompareTo(*right) <= 0)
     {
         return;
     }
     Swap(left, right);
 }
示例#3
0
 static unsafe void InsertionSort <TX>(TX *left, TX *right) where TX : unmanaged, IComparable <TX>
 {
     for (var i = left; i < right; i++)
     {
         var j = i;
         var t = *(i + 1);
         while (j >= left && t.CompareTo(*j) < 0)
         {
             *(j + 1) = *j;
             j--;
         }
         *(j + 1) = t;
     }
 }