public void AddNewWordToStructure(string word) { if (string.Equals(word.GetLetterFromStringPosition(0), this._treeNode)) { if (!(this._dataDictionary.Count == 0)) { if (word.Length == 1) { this._dataDictionary.Clear(); } else { SingleTree newNode = new SingleTree(); if (this._dataDictionary.ContainsKey(word.GetLetterFromStringPosition(1))) { newNode.AddNewWordToStructure(word.Substring(1)); } else { this._dataDictionary.Add(word.GetLetterFromStringPosition(1), new SingleTree(word.Substring(1))); } } } } }
public void AddNewWordToStructure(string word) { SingleTree newNode = null; if (word.Length >= 4) { if (this._dataDictionary.ContainsKey(word.GetLetterFromStringPosition(0))) { newNode = this._dataDictionary[word.GetLetterFromStringPosition(0)]; } if (newNode == null) { this._dataDictionary[word.GetLetterFromStringPosition(0)] = new SingleTree(word); } else { newNode.AddNewWordToStructure(word); } } }