调整目录结构

This commit is contained in:
2025-08-29 09:11:08 +08:00
parent efb64ce7bc
commit 1fff9db9ca
351 changed files with 304 additions and 215 deletions

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
namespace NBF
{
public static class AlgorithmUtils
{
#region
public static void QuickSortRecursive<T>(IList<T> dataList, int left, int right, Comparison<T> comparer)
{
if (dataList == null)
throw new ArgumentNullException();
if (comparer == null)
throw new ArgumentNullException();
if (left >= right)
return;
int mid = QuickSortPatition(dataList, left, right, comparer);
QuickSortRecursive(dataList, left, mid - 1, comparer);
QuickSortRecursive(dataList, mid + 1, right, comparer);
}
private static int QuickSortPatition<T>(IList<T> dataList, int left, int right, Comparison<T> comparer)
{
int j = left;
int i = j - 1;
T equipKey = dataList[right]; //基准元素
for (; j < right; ++j)
{
if (comparer(dataList[j], equipKey) < 0)
{
SwapData(dataList, j, ++i);
}
}
//把right交换到中间
T t = dataList[right];
dataList[right] = dataList[++i];
dataList[i] = t;
return i;
}
private static void SwapData<T>(IList<T> dataList, int x, int y)
{
T tmp = dataList[x];
dataList[x] = dataList[y];
dataList[y] = tmp;
}
#endregion
}
}