Use HashTable in TrieNode.

This commit is contained in:
Oleksii Trekhleb 2018-05-31 21:37:13 +03:00
parent 5b3de38cca
commit e6de25ecb3

View File

@ -1,8 +1,10 @@
import HashTable from '../hash-table/HashTable';
export default class TrieNode { export default class TrieNode {
constructor(character, isCompleteWord = false) { constructor(character, isCompleteWord = false) {
this.character = character; this.character = character;
this.isCompleteWord = isCompleteWord; this.isCompleteWord = isCompleteWord;
this.children = new Map(); this.children = new HashTable();
} }
getChild(character) { getChild(character) {
@ -22,7 +24,7 @@ export default class TrieNode {
} }
suggestChildren() { suggestChildren() {
return [...this.children.keys()]; return [...this.children.getKeys()];
} }
toString() { toString() {