private bool __find(string path, int startIndex) { if (path.Length - startIndex <= 0) { return(false); } // 找到第一个'.'的位置 int pos = path.IndexOf('.', startIndex); if (pos == startIndex) // 头一个字符就是'.',视为非法输入 { return(false); } // 得到'.'前面的部分,例如"foo" string str; if (pos != -1) { str = path.Substring(startIndex, pos - startIndex); } else { str = path.Substring(startIndex, path.Length - startIndex); } // 查找str是否为一个已经存在的child LogTrie child = __findChild(str, true); if (child == null) { return(false); } if (pos != -1 && child.m_str != "*") { // 递归处理余下的path return(child.__find(path, pos + 1)); } else { // path已经结束,若当前节点是一个终结符节点,则说明找到 return(child.m_terminal); } }