# 排序提取的算法

www.MyException.Cn  网友分享于：2013-03-30  浏览：6次

http://forum.csdn.net/PointForum/Forum/PostTopic.aspx
http://forum.csdn.net/
http://csdn.net/
....

------------------------------------

http://csdn.net/ 重复1000次
http://forum.XXXX.net/ 重复800次
http://XX.net/ 重复500次
.....

------解决方案--------------------
C# code
```
public class TCount
{
private string _Url;
public string Url {
get { return _Url; }
set { _Url = value; }
}
private int _Count;
public int Count {
get { return _Count; }
set { _Count = value; }
}

public TCount(string _Url, int _Count) {
this._Url = _Url;
this._Count = _Count;
}
}
public class DoCount {
private string _FilePath;
public string FilePath {
get { return _FilePath; }
set { _FilePath = value; }
}
public DoCount(string _FilePath) {
this._FilePath = _FilePath;
}

/// <summary>
/// 读取数据,并统计
/// </summary>
/// <returns></returns>
public IList<TCount> CountUrl() {
IList<TCount> IT = new List<TCount>();
}
sr.Close();
return IT;
}

private IList<TCount> ReCorrectCount(IList<TCount> IT, string url) {
int i = 0;
bool blnIn = false; //用于标识url是否已存在于IT中
foreach(TCount T in IT){
if (T.Url == url) { //如果存在,则更新统计数
IT[i].Count += 1;
blnIn = true;
break;
}
i++;
}
if (!blnIn)//如果不存在则添加新项