You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Semantic/Model/CharTrieNode.cs

38 lines
1.0 KiB

using System;
namespace ZeroLevel.Services.Semantic.Model
{
internal class CharTrieNode(char key)
{
public char Key { get; } = key;
public virtual bool IsTerminal => false;
public CharTrieNode[] Children { get; set; } = [];
public void AddChild(CharTrieNode node)
{
var children = new CharTrieNode[Children.Length + 1];
Array.Copy(Children, children, Children.Length);
children[^1] = node;
Children = children;
}
public void RemoveChildAt(int index)
{
var children = new CharTrieNode[Children.Length - 1];
Children[index] = Children[^1];
Array.Copy(Children, children, children.Length);
Children = children;
}
public void CopyChildren(CharTrieNode[] toCopy)
{
Children = new CharTrieNode[toCopy.Length];
Array.Copy(toCopy, Children, Children.Length);
}
public override string ToString() => $"Key: {Key}";
}
}

Powered by TurnKey Linux.