Ejemplo n.º 1
0
 internal Node(Node parent, Char c)
 {
     _parent = parent;
     _char = c;
     _values = new List<string>();
     _transitions = new Dictionary<Char, Node>();
 }
Ejemplo n.º 2
0
        private void AddKeyword(string keyword)
        {
            if (string.IsNullOrEmpty(keyword))
                throw new ArgumentException();

            Node current = _root;
            foreach (var item in keyword)
            {
                Node next = null;
                foreach (var transition in current.Transitions)
                {
                    if (transition != null && transition.Char.CompareTo(item) == 0)
                    {
                        next = transition;
                        break;
                    }
                }

                if (next == null)
                {
                    next = new Node(current, item);
                    current.AddTransition(next);
                }

                current = next;
            }
            current.AddValue(keyword);
            current.Lable = keyword;
        }
Ejemplo n.º 3
0
 internal void AddTransition(Node node)
 {
     _transitions.Add(node.Char, node);
 }