詳細的代碼下載下面的代碼項目進行了解。
測試DEMO:
/// <summary>
/// 向上移動
/// </summary>
private static void StartTestDataStructMoveUp()
{
Console.WriteLine("-------------待排序的數據--------------");
List<MoveSeqArithmeticItem<object, string>> list = new List<MoveSeqArithmeticItem<object, string>>();
for (int i = 0; i < 10; i++)
{
MoveSeqArithmeticItem<object, string> o = new MoveSeqArithmeticItem<object, string>(i, string.Format("key{0}", i), null);
list.Add(o);
}
//構造數據結構,並加入數據
MoveSeqArithmetic<object, string> s = new MoveSeqArithmetic<object, string>(list.ToArray<MoveSeqArithmeticItem<object, string>>());
//向上移動數據
s.MoveUpByKeys(new object[] { "key0" });
s.MoveUpByKeys(new object[] { "key2", "key3", "key4" });
s.MoveUpByKeys(new object[] { "key9" });
//打印
foreach (MoveSeqArithmeticItem<object, string> item in s.ArrList)
{
Console.WriteLine(string.Format("Seq: {0} --- Key: {1}", item.Seq, item.ObjKey));
}
}
執行結果上面已經展示。