CPF/CPF.Windows/Json/Formatter/Internal/CharTries.cs
2023-11-21 23:05:03 +08:00

37 lines
1011 B
C#

using System.Collections.Generic;
namespace CPF.Windows.Json.Deserialize
{
internal class CharTries
{
internal char Val;
internal MemberExtension Member;
internal bool IsPeak;
internal bool IsValue;
internal CharTries Parent;
internal List<CharTries> Childrens;
internal CharTries() {
Childrens = new List<CharTries>();
IsValue = false;
}
internal void Insert(string str,MemberExtension mem)
{
CharTries charTries = this;
foreach (var c in str)
{
var @case = charTries.Childrens.Find(e => e.Val == c);
if (@case == null)
{
@case = new CharTries() { Val = c, Parent=charTries };
charTries.Childrens.Add(@case);
}
charTries = @case;
}
charTries.IsValue = true;
charTries.Member = mem;
}
}
}