public void InsertWord(string word) { if (string.IsNullOrEmpty(word)) { return; } char[] chs = word.ToCharArray(); int index = 0; FNode nextNode = null; while (index < chs.Length) { ushort key = (ushort)chs[index++]; if (nextNode == null) { nextNode = FTreeHelper.BinaryInsert(key, childs); } else { nextNode = nextNode.InsertChild(key); } } nextNode.terminated = true; }
public bool Process(char[] chs, int offset, ref int result) { FNode nextNode = null; result = -1; int index = offset; while (index < chs.Length) { ushort key = (ushort)chs[index++]; if (nextNode == null) { nextNode = FTreeHelper.BinarySearch(key, childs); } else { nextNode = nextNode.BinarySearch(key); } if (nextNode == null) { break; } if (nextNode.terminated) { result = index; } } return(result != -1); }
public FNode InsertChild(ushort key) { if (childs == null) { childs = new List <FNode>(); } return(FTreeHelper.BinaryInsert(key, childs)); }
public FNode BinarySearch(ushort key) { if (childs == null) { return(null); } return(FTreeHelper.BinarySearch(key, childs)); }