declare class Trie { private root; private wordCount; /** * 字典树中有多少个单词 */ getWordCount(): number; /** * 插入单词 */ insert(word: string): void; /** * 搜索指定前缀的最后一个节点 */ private searchPrefixNode; /** * 是否存在 */ search(word: string): boolean; /** * 前缀是否存在 */ startsWith(prefix: string): boolean; /** * 移除 */ remove(word: string): boolean; /** * 不保证遍历的顺序 */ forEach(callback: (word: string) => void): void; private forEachImpl; /** * 转换成数组 */ toArray(): string[]; /** * 清空字典树 */ clear(): void; /** * 将数组转换成字典树 */ static fromArray(words: string[]): Trie; } export default Trie;