主要算法如代码所示
| 以下是引用片段: private static Dictionary dic = new Dictionary(); private static BitArray fastcheck = new BitArray(char.MaxValue); static void Prepare() { string[] badwords = // read from file foreach (string word in badwords) { if (!dic.ContainsKey(word)) { dic.Add(word, null); maxlength = Math.Max(maxlength, word.Length); int value = word[0]; fastcheck[word[0]] = true; } } } |
使用的时候
| 以下是引用片段: int index = 0; while (index < target.Length) { if (!fastcheck[target[index]]) { while (index < target.Length - 1 && !fastcheck[target[++index]]) ; } for (int j = 0; j < Math.Min(maxlength, target.Length - index); j++) { string sub = target.Substring(index, j); if (dic.ContainsKey(sub)) { sb.Replace(sub, "***", index, j); index += j; break; } } index++; } |

一沙一世界 一花一天堂 掌中握無……

网络编程技术、多媒体技术、PC应用技术

| 我爱研发网 | 中电华信 | 阿里西西 | JAVA爱好者 | 北京英才网 | 全球大学查询网 |
| 中国人的网站导航 | 中国电脑论坛 | 信息产业部 | 新浪科技 | 搜狐IT | 信息产业部电子教育与考试中心 |
| IT世界网 | 软件项目交易网 | 中国软件交易网 | 国信培训网 | 亚远景科技 | ....[更多] |