示例#1
0
    public static bool CheckSensitiveWorld(string txt)
    {
        SensitiveWorld node = null;

        for (int i = 0; i < txt.Length; i++)
        {
            Debug.Log(i + ":" + txt[i]);
            node = node == null?sensitiveNodes.GetNode(txt[i]) : node.GetNode(txt[i]);     // 三目运算符  node =  a==b ?c:d  // true c    false d

            if (node != null && node.isLast)
            {
                Debug.LogFormat("node:{0} isLast:{1}", node, node.isLast);
                return(true);
            }
        }
        return(false);
    }
示例#2
0
    public static void InitSensitiveWorld(string world)
    {
        if (string.IsNullOrEmpty(world))
        {
            return;
        }
        Debug.Log("world0:" + world[0]);
        SensitiveWorld node = sensitiveNodes.AddNode(world[0]);   // key  对应的 value(node)

        for (int i = 1; i < world.Length; i++)
        {
            Debug.Log("world[i]:" + world[i]);
            node = node.AddNode(world[i]);
        }

        node.isLast = true;
    }