在这里编写基于 Reddit 的排序算法:http: //amix.dk/blog/post/19588
由于某些 System.Math 签名在它们的应用程序中不同,我很难将它们组合在一起。
public class Calculation
{
protected DateTime Epoch = new DateTime(1970,1,1);
protected int EpochSeconds(DateTime date)
{
var td = date - Epoch;
return td.Days*86400 + td.Seconds + ((td.Milliseconds)/1000000);
}
protected int Score(int upVotes,int downVotes)
{
return upVotes - downVotes;
}
public int HotScore(int upVotes,int downVotes,DateTime date)
{
var s = Score(upVotes, downVotes);
var order = Math.Log(Math.Max(Math.Abs(s), 1), 10);
var sign = Math.Sign(s); //Edit from Jonathon Reinhart
var seconds = EpochSeconds(date) - 1134028003;
return Math.Round(order + sign + *seconds/45000, 7);
}
}
编辑以获取更多信息
具体来说,我在最后一行遇到错误
return Math.Round(order + sign + *seconds/45000, 7);
//error "The * or -> operator must be applied to a pointer"
"
我可以在方法签名中找到的最接近的匹配是:http: //msdn.microsoft.com/en-us/library/f5898377