本文整理汇总了C#中System.Thread.Less方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.Less方法的具体用法?C# Thread.Less怎么用?C# Thread.Less使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Thread
的用法示例。
在下文中一共展示了Thread.Less方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QSort
private static void QSort( Thread thread, Table list,
Callable less, int l, int u )
{
while( l < u )
{
var vl = list[l];
var vu = list[u];
if( thread.Less( vu, vl, less ) )
{
//swap
var tmp = vl;
vl = vu;
vu = tmp;
list[l] = vl;
list[u] = vu;
}
if( u - l == 1 )
//only had two elements
break;
var i = (l + u) / 2;
var vi = list[i];
if( thread.Less( vi, vl, less ) )
{
var tmp = vl;
vl = vi;
vi = tmp;
list[l] = vl;
list[i] = vi;
}
else if( thread.Less( vu, vi, less ) )
{
var tmp = vu;
vu = vi;
vi = tmp;
list[u] = vu;
list[i] = vi;
}
if( u - l == 2 )
//only had three elements
break;
var vp = vi;
var j = u - 1;
var vj = list[j];
list[j] = vi;
list[i] = vj;
i = l;
for( ; ; )
{
while( thread.Less( vi = list[++i], vp, less ) )
{
if( i >= u )
throw new ArgumentException( "Invalid sort function." );
}
while( thread.Less( vp, vj = list[--j], less ) )
{
if( j <= l )
throw new ArgumentException( "Invalid sort function." );
}
if( j < i )
break;
list[i] = vj;
list[j] = vi;
}
list[u - 1] = list[i];
list[i] = vp;
if( i - l < u - i )
{
j = l;
i--;
l = i + 2;
}
else
{
j = i + 1;
i = u;
u = j - 2;
}
QSort( thread, list, less, j, i );
}
}