mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-04-05 17:37:51 +08:00
37 lines
1011 B
C#
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;
|
|
}
|
|
}
|
|
}
|