mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 23:21:18 +08:00
Use HashTable in TrieNode.
This commit is contained in:
parent
5b3de38cca
commit
e6de25ecb3
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user