Exemplo n.º 1
0
 public int CompareTo(BaseNode <T> other)
 {
     if (_c > other.GetChar())
     {
         return(1);
     }
     if (_c < other.GetChar())
     {
         return(-1);
     }
     return(0);
 }
Exemplo n.º 2
0
        public override bool AddChild(BaseNode <T> node)
        {
            bool         add    = false;
            char         c      = node.GetChar();
            BaseNode <T> target = GetChild(c);

            if (target == null)
            {
                _child[c] = node;
                add       = true;
            }
            else
            {
                switch (node.NodeStatus)
                {
                case Status.UNDEFINED_0:
                    if (target.NodeStatus != Status.NOT_WORD_1)
                    {
                        target.NodeStatus = Status.NOT_WORD_1;
                        add = true;
                    }
                    break;

                case Status.NOT_WORD_1:
                    if (target.NodeStatus == Status.WORD_END_3)
                    {
                        target.NodeStatus = Status.WORD_MIDDLE_2;
                    }
                    break;

                case Status.WORD_END_3:
                    if (target.NodeStatus == Status.NOT_WORD_1)
                    {
                        target.NodeStatus = Status.WORD_MIDDLE_2;
                    }
                    if (target.Value == null)
                    {
                        add = true;
                    }
                    target.Value = node.Value;
                    break;
                }
            }
            return(add);
        }