這次講使用基數排序int數據類型..

using System;

using System.Collections.Generic;

using System.Text;


namespace WindowsApplication3


...{

public class IntRadixSortItem : RadixSortItem


...{

int value;

public int Value


...{

get


...{

return value;

}

}


public IntRadixSortItem(int Value)


...{

value = Value;

if (value < 0)


...{

IsNegative = true;

}

else


...{

IsNegative = false;

}

Data = BitConverter.GetBytes(Value);

DataLen = 4;

}

public override string ToString()


...{

return value.ToString() + " " + Data[0].ToString("X2")

+ " " + Data[1].ToString("X2")

+ " " + Data[2].ToString("X2")
+ " " + Data[3].ToString("X2");

}


}

}
其實我很早就會使用基數排序正整數,但是對於負數一致不太明白.多次查閱資料,沒有一個范例說基數可以正確排序整數和負數的混合集合..因此采取了分別處理的方法...可以看到這個IsNegative屬性..就是告訴排序器分別處理正數以及負數的... 待續...