private string GetItem(string key) { KeywordTrieNode state = this; foreach (var ch in key) { state = state.GetChild(ch); if (state.IsNull()) { return(null); } } return(state.Value); }
private void SetItem(string key, string value) { KeywordTrieNode state = this; for (int i = 0; i < key.Length; i++) { if (i < key.Length - 1) { state = state.AddChild(key[i]); } else { var child = state.GetChild(key[i]); state = state.AddChild(key[i], value, true); if (child.IsNull() || !child.HasValue) { Count += 1; } } } }